locked
QueryString lost when attempting to read in ASPX page RRS feed

  • Question

  • User79768571 posted

    I have some fairly simple code that works perfectly on my local machine, but when run on the server I'm deploying it to, acts very differently.

    If I type into the url bar of the browser:

    localhost/page.aspx?param1=blah

    I can write the parameter to a label and see that it gets passed perfectly.

    When I deploy it to the Server 2016 instance

    The url remains with parameters and I can clearly see that no parameters are making it to the Request.QueryString["param1"]; call

    This is a fresh install and so I'm confused as to why it's acting so differently between IIS10 on windows 10 and IIS10 on 2016.

    Any ideas?

    Thursday, June 20, 2019 11:36 PM

Answers

  • User79768571 posted

    I've resolved this.

    For whatever reason, when the copy was being made to the server (I assume permissions in the rdp session), the aspx file was copying just fine but the bin folder was not being refreshed. I've replicated over the bin folder and am now seeing the expected results.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 25, 2019 8:10 PM

All replies

  • User-1038772411 posted

    Hi, valdier

    protected void PostButton_Click(object sender, EventArgs e)
    {
            Response.Redirect("~/default.aspx?title=" + textbox1.text);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
           if (!Page.IsPostBack)
            {
    
                // Get Querystring for Title, if it exists
                string pageTitle = Request.QueryString["title"];
                
                if (!string.IsNullOrEmpty(pageTitle))
                {
                   PageTitleTextBox.Text = pageTitle;          
                }
            }
    }

    You can refer below link for more understanding

    https://forums.asp.net/t/1227529.aspx?Request+Querystring+is+truncating+parameters

    Friday, June 21, 2019 6:35 AM
  • User79768571 posted

    I'm aware of how to get the request parameters from the query string.

    What I mentioned was, the querystring parameters are "dropped" when I run the aspx page on the server vs on a local box.

    Friday, June 21, 2019 3:33 PM
  • User79768571 posted

    Just bumping hoping for some insight

    Monday, June 24, 2019 4:42 PM
  • User61956409 posted

    Hi Valdier,

    The above code sees the parameter on my local machine, or when run from VS with IIS Express. On the server it ignores the parameter string (testing for parameters shows no parameters are ever sent)

    Do you mean that you always can not get QueryString in your code when you browse web page http(s)://xxxx/page.aspx?report=blahblah hosting on your IIS?

    With Regards,

    Fei Han

    Tuesday, June 25, 2019 7:47 AM
  • User753101303 posted

    Which value do you see in Label1/Label2 so that we can understand which branch is taken? You really saw directly no QueryString is found (ie QueryString.AllKeys.Length or something like that)  or do you assume that based on the code behavior.

    Make sure to code for what you expect. For example retuning null on an Exception could be counter productive.

    Ultimately if I really have a doubt about the incoming http request, I'm using https://docs.microsoft.com/en-us/dotnet/api/system.web.httprequest.saveas?view=netframework-4.8 to save and inspect the request but for now I rather expect what happens is currenly obscured by your code.

    Tuesday, June 25, 2019 9:16 AM
  • User79768571 posted

    Yes, when running on the Server 2016 instance, I get no query string results at all. When running on local (IIS on Win 10, or IIS Express), I get the expected results and my application is able to process the string.

    I have to assume it's some kind of setting that must be configured on the Server instance, but can't for the life of me find anything that would apply.

    Tuesday, June 25, 2019 3:24 PM
  • User79768571 posted

    Ok, good, question... this opened up another whole line of not know whats happening.

    Resolved, not a code issue.

    Tuesday, June 25, 2019 3:58 PM
  • User79768571 posted

    I have gone in to check that .aspx is set to prevent all caching both at user mode and kernel mode (and restarted the server).

    Tuesday, June 25, 2019 4:58 PM
  • User79768571 posted

    I've resolved this.

    For whatever reason, when the copy was being made to the server (I assume permissions in the rdp session), the aspx file was copying just fine but the bin folder was not being refreshed. I've replicated over the bin folder and am now seeing the expected results.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 25, 2019 8:10 PM