In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the difference between Form Collection and Request.Form in Asp.net." Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. What is the difference between Form Collection and Request.Form in Asp.net?
Difference between FormCollection and Request.Form:
We recommend using FormCollection for two reasons:
1. The former facilitates unit testing:
For Action unit testing, FormCollection is used as an input parameter, which is simpler than Request.Form. You can simulate a FormCollection by writing the following code:
[csharp]view plaincopyprint?
varform=newFormCollection();
form.Add("fieldName","fieldValue");
2. The former supports MVC extensions:
Asp.net MVC binds user input to FormCollection when binding the model. By default, the content in FormCollection is consistent with Request.Form. However, when we customize ModelBinder, it will affect the value of FormCollection, while Request.Form will not affect it. So if we still use Request.Form when customizing ModelBinder, customizing ModelBinder is useless.
Request.form and Request.QueryString
Request. form method, which is used to receive form variables (post method)
2. Request. QueryString method, which is the (get method) that receives URL parameters
3.Request object can also not specify the specific use of QueryString or form methods, such as request("variable"), because it can automatically identify, but it is still indicated as good, otherwise, it will take a little time to judge itself, affecting the efficiency of program execution. Request: contains the above two methods (priority to get the data submitted by GET method), it will search in QueryString, Form, ServerVariable.
In addition to receiving different methods, there is also the problem of passing data size. The request.form method can receive no limit on the data, while the request.QueryString can only receive data less than 2KB. Of course, the latter is faster than the former. Generally, request.QueryString method is used when requesting queries from databases, because there are only a few keywords when querying, and there is no need to use request.form method to slow down the query speed. In addition, the request.QueryString method also displays data information in the client browser address bar, which is less secure. The request.form method does not suffer from these problems, and is therefore widely used in situations where data is submitted and users log in from multiple text fields.
At this point, I believe that everyone has a deeper understanding of "what is the difference between Form Collection and Request.Form in Asp.net." It is advisable to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.