Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7835577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:42:04+00:00 2026-06-02T13:42:04+00:00

I am re-writing an ASP.NET application and noticed a difference in behaviour … In

  • 0

I am re-writing an ASP.NET application and noticed a difference in behaviour …

In my Page_Load event I have some code such as:

string id = Request["id"]

which gets the id param from the URL. On page load (ie a HTTP GET), this works as expected in both versions. I also have a button onclick event handler. Clearly, this performs a POST to the server, and also invokes the Page_Load handler. The difference is, that in the original version of the app, the id is successfully loaded from the request. In the new version of the app, id comes back as null. I have discovered that I need to use Request.Params[“id”] instead, but am totally puzzled as to why Request[“id”] works for POST requests in one app but not the other.

The only difference between the apps is that the first was created as File -> New Website and the second File -> New Web Application. I think this is what is causing the difference in behaviour, but am wondering why this subtle difference, and also if there is anything else I should be aware of between the 2.

Any advice greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:42:05+00:00Added an answer on June 2, 2026 at 1:42 pm

    As you have mentioned, you have the id parameter coming through twice. This will be because you have one in the query string parameters and one in the form parameters. I’m not sure why this would be occurring in one web app and not the other, but you can make changes to your code to account for it in a more correct way.

    If you view the source of the HTML in your browser, you will see that the action value for the form will be current pages URL, including the query string. This is why the first id is being sent through. Evidently, the second id is coming through via the form itself:

    HTML Source of basic web form

    <form method="post" action="Default.aspx?id=3" id="ctl01">
        <input type="text" name="id">
    </div>
    

    There are a couple of things you can do here:

    1. first off, I wouldn’t use Request.Params[“id”] for this, as it combines the query string, form, cookies and server variables into one collection. You should use Request.Querystring and Request.Form properties, based on what you require and when
    2. In your Page_Load handler, use the Page.IsPostBack property to determine whether the page is loading for a GET or POST and use the Request properties described above.

    Example of Page.IsPostBack usage:

    protected void Page_Load(object sender, EventArgs e)
    {
        string id = string.Empty;
        if (Page.IsPostBack)
        {
            id = Request.Form["id"];
        }
        else
        {
            id = Request.QueryString["id"];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the ASP.Net application I am writing I need to be able to have
In a asp.net/c# web application I am writing a jQuery script. I have an
I'm writing my first asp.net mvc application and I have a question about custom
I'm writing and installer for an ASP.NET application, and I have a few data
I am writing an ASP.NET application that initializes some contextual data based on stuff
I'm writing an ASP.net MVC3 application using Entity Framework Code First and SqlCe4. I
I have an ASP.NET application which tracks statistics by creating and writing to custom
I am writing an ASP.NET 4 application with C#. I have a Master Page,
I am writing an ASP.NET MVC 3 application and I have a number of
I am writing an asp.net application and have a form where a user must

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.