What is the difference between request and request.querystring
Notify me of new posts via email. QueryString collection In Request. Share this: Twitter Facebook. Like this: Like Loading Screen-reader not work for focus-trap div. Leave a Reply Cancel reply Enter your comment here Fill in your details below or click an icon to log in:. QueryString collection. In Request. Form the data is posted in the http request body whereas in QueryString data is sent through url. It is also faster for the system if you specify the location of the information. Form : The value of Request.
Form element is an array of all the values of element that occur in the request body. You can determine the number of values of a parameter by calling Request. Form element. The order in which they are searched is not specified in the documentation but when you take a look at the source code you'll see that it is the order in which they are mentioned. So if you know where your variable resides, which you usually do, it's better to use the more specific option.
According to the documentation the HttpRequest indexer. I'd prefer using Request. QueryString["id"] since it's more explicit where the value is coming from. QueryString ["id"] looks into the collection passed per QueryString. Therefore the QueryString Property should be preferred when possible because it is smaller. QueryString["id"] will return the value of an item in the query string that has a key of id , whereas Request["id"] will return an item from one of Request.
QueryString, Request. Form, Request. Cookies, or Request. It's worth mentioning that the documentation for Request. Item which is what you're actually accessing when you call Request["id"] does not specify the order in which the collections will be searched, so you could theoretically receive a different result depending on which version of asp. If you know that the value you want is in your query string, it's always better to use Request. QueryString["id"] to access it, rather than Request["id"].
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem.
Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid. Related Questions. QueryString Question. Difference between Application and session variable. What is a difference between cookie and session. Difference between user. Difference between Sessions and View state.
Difference between cookies and session.
0コメント