querystring length

Discussion in 'ASP General' started by displayname, Aug 14, 2008.

  1. displayname

    displayname Guest

    I have an ASP page with a button and other things.
    When the button is clicked, it executes a javascript function which does:

    document.Form1.method = 'post';
    document.Form1.action = "AnotherASPpage.asp?p1=" + allFields1 + "&p2=" +
    allFields2 + "&p3=" + bVar;
    document.Form1.submit();

    allFields1 represents all the fields in category 1 that user has selected.
    The fields are delimited by comma.
    allFields2 represents all the fields in category 2 that user has selected.
    The fields are delimited by comma.

    The AnotherASPpage.asp is supposed to display the result in Excel spreadsheet.

    I test it by selecting 15 fields in category 1 and it pops up a File
    Download small window asking if I want to Open, Save, or Cancel the Excel
    file. It shows an Excel name like abc.xls in the Name: section in that small
    window. I can Save the file successfully.

    But, when I select 16 fields in category 1, pops up a File Download small
    window asking if I want to Open, Save, or Cancel the Excel file. But, it
    doesn't show an Excel name like abc.xls in the Name: section in that small
    window. It shows ..., id1%20AS%20... When I click Save, it gives error about
    IE can't download ...&p3=...

    It looks like the limit of the querystring in the URL is too long. But with
    POST method the limit is huge and I'm no where near that limit.

    I am thinking about using hidden variables to pass data from one page to
    another but I can't because onclick of a button page1 invokes a javascript
    function which submits AnotherASPpage.asp and thus doesn't know about the
    hidden variables from page1.

    Can someone please help? Thanks.
    displayname, Aug 14, 2008
    #1
    1. Advertising

  2. displayname wrote:
    > I have an ASP page with a button and other things.
    > When the button is clicked, it executes a javascript function which
    > does:
    >
    > document.Form1.method = 'post';
    > document.Form1.action = "AnotherASPpage.asp?p1=" + allFields1 +
    > "&p2=" + allFields2 + "&p3=" + bVar;
    > document.Form1.submit();
    >
    > allFields1 represents all the fields in category 1 that user has
    > selected. The fields are delimited by comma.
    > allFields2 represents all the fields in category 2 that user has
    > selected. The fields are delimited by comma.
    >
    > The AnotherASPpage.asp is supposed to display the result in Excel
    > spreadsheet.
    >
    > I test it by selecting 15 fields in category 1 and it pops up a File
    > Download small window asking if I want to Open, Save, or Cancel the
    > Excel file. It shows an Excel name like abc.xls in the Name: section
    > in that small window. I can Save the file successfully.
    >
    > But, when I select 16 fields in category 1, pops up a File Download
    > small window asking if I want to Open, Save, or Cancel the Excel
    > file. But, it doesn't show an Excel name like abc.xls in the Name:
    > section in that small window. It shows ..., id1%20AS%20... When I
    > click Save, it gives error about IE can't download ...&p3=...
    >
    > It looks like the limit of the querystring in the URL is too long.
    > But with POST method the limit is huge and I'm no where near that
    > limit.
    >
    > I am thinking about using hidden variables to pass data from one page
    > to another but I can't because onclick of a button page1 invokes a
    > javascript function which submits AnotherASPpage.asp and thus doesn't
    > know about the hidden variables from page1.
    >

    I don't understand the problem. In the form's onsubmit event, populate the
    hidden elements with the required values. Forget about the querystring.

    What's the problem?

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Aug 14, 2008
    #2
    1. Advertising

  3. displayname

    displayname Guest

    "Bob Barrows [MVP]" wrote:

    > I don't understand the problem. In the form's onsubmit event, populate the
    > hidden elements with the required values. Forget about the querystring.
    >
    > What's the problem?


    After user selects all the fields, there's need to have a way to tell the
    program to query the data and display the result in Excel. The button is a
    way to let the user do that.
    Here's the sequence of events:
    1) page1.asp is rendered
    2) user selects some fields from page1 and click the button
    3) can page1.asp sets some hidden variables to indicate which fields the
    user has just selected at this point?
    4) page1.asp redirects to AnotherASPpage which needs to know which fields
    the user selected.
    5) AnotherASPpage.asp queries the database for those selected fields and
    displays the result in Excel.
    6) user still sees page1.asp and doesn't see AnotherASPpage.asp at all.
    displayname, Aug 14, 2008
    #3
  4. Bob Barrows [MVP] wrote:
    > I don't understand the problem. In the form's onsubmit event,
    > populate the hidden elements with the required values. Forget
    > about the querystring.
    > What's the problem?


    For one thing, hidden inputs can very much impact the length of the
    querystring. The OP's red herring is setting the form method to "post",
    while littering the action with name-value pairs. His script is, in effect,
    reading the querystring.

    The problem with using POST and returning an ASP document with ContentType =
    "application/vnd.ms-excel" (or
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" if Excel
    2007) is that Internet Explorer handles the response, determines that the
    ContentType requires an external application, then hands over the URL (not
    the response stream) to Excel. At this point, Excel knows nothing about the
    original POST, and submits a new request with the querystring only. This can
    be confirmed by reading the IIS logs.

    Gecko Browsers have no such problem.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
    Dave Anderson, Aug 14, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Bilbee

    Querystring length

    Kevin Bilbee, Nov 7, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    4,091
    Josh Brown
    Nov 7, 2003
  2. Mehdi
    Replies:
    6
    Views:
    36,095
    sloan
    Apr 6, 2006
  3. Adam Eccleshall

    Alternative options for when QueryString exceeds IE URL length lim

    Adam Eccleshall, Aug 19, 2009, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    1,225
    Patrice
    Sep 1, 2009
  4. Jawahar Rajan

    QueryString MAx Length

    Jawahar Rajan, Sep 5, 2003, in forum: ASP General
    Replies:
    3
    Views:
    210
    Mark Schupp
    Sep 5, 2003
  5. Adeel Ahmad
    Replies:
    1
    Views:
    432
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page