ASP. NET Status Management 2 (querystring)

Source: Internet
Author: User

The query string is the data appended to the URL (which is also commonly used)

For example:
Http://www.cnblogs.com/aierong/admin/EditPosts.aspx? Opt = ABC
Here? The later opt = 1 is the query string

This method can be used when data is transmitted to another page on one page.

Use the following method to receive data:
String STR = request. querystring ["Opt"]
In this way, STR is equal to "ABC".

Here we are passing English characters. If we want to pass Chinese characters, do we have to encode and reconcile them:
When sending the message, use the server. urlencode method to parse the response. When receiving the message, use server. urldecode to parse the response.

For example:
Transfer:
String url = "http://www.cnblogs.com/aierong/admin/EditPosts.aspx? Opt = "+ server. urlencode (" we ");
Response. Redirect (URL );
Receive:
String STR = server. urldecode (request. querystring ["Opt"]);
In this way, STR is equal to "we"

Of course, we have another easy-to-use method:

Modify globalization in Web. config
<Globalization
Requestencoding = "gb2312"
Responseencoding = "gb2312"
/>

Summary

The query string is the information appended at the end of the page url.

You can use a query string to submit data back to your page or another page through a URL.
Querying strings provides a simple but limited way to maintain certain State information.
For example, they are a simple way to transfer information from one page to another (for example, to another page that will process the product number ).

Advantages of using a query string
1. No server resource is required: the query string is contained in an HTTP request to a specific URL.
2. Extensive support: almost all browsers and client devices support using query strings to pass values.
3. Simple implementation: ASP. NET fully supports the string query method, including the method for reading the query string using the Params attribute of the httprequest object.

Disadvantages of using a query string
1. potential security risks
You can directly view the information in the query string on the browser user interface.
You can set this URL as a bookmark or send it to another user to pass the information in the query string through this URL.
If you are concerned about querying any sensitive data in a string, consider using a hidden field in a form (using post instead of a query string.

2. Limited Capacity
Some browsers and client devices have a URL length limit of 2083 characters.

 

 

SQL server2005 Transact-SQL new weapon learning Summary-Summary
Backup and restoration of stored procedures in ms SQL database (enhanced version)
SQL Server Distributed Query (sp_addmediaserver) and remote logon ing (sp_addmediasrvlogin)
WAP development site (latest update)
Custom Format String (implementation of iformattable, iformatprovider, and icustomformatter)
asynchronous programming of mcad learning notes (asynccallback delegate, iasyncresult interface, begininvoke method, summary of the use of the endinvoke method)
mcad learning notes call the class method, attention, field, indexer through reflection (two methods)
serialization of mcad learning notes (binary and soap serialization)
delegate re-understanding of mcad learning notes (Delegate constructor, begininvoke, endinvoke, invoke4 methods)
winform development, summary of information about form display and form value passing
Microsoft Windows Service for mcad Study Notes
copy all the objects and files under a certain category to the target category (Object quota quota)
Asp. net status management (Summary)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.