Url encoding and decoding of c # in ASP. NET

Source: Internet
Author: User

Problems to be Solved:
Upload the following URL as a parameter to other pages
1 http: // domain/de. retrial? Uid = 12 & page = 15
2. The parameters following the url contain Chinese characters, such as:... aspx? Title = crane
In the above case, an RUL encoding and decoding process must be performed; otherwise, an error may occur.
 

The Code is as follows:
<A href = "DictEdit. aspx? Dict = <% # Eval ("SourceLang") %> & target = <% # Eval ("TargetLang") %> & Email = <% # Eval ("UserEmail ") %> & Word = <% # System. web. httpUtility. urlEncode (Eval ("Word "). toString () %> "> </a>

1 // pass the value
2 string temp = "<a href = 'add. aspx? Url = "+ Server. urlEncode (skin. page. request. url. absoluteUri) + "& title =" + Server. urlEncode (skin. page. header. title) + "'> Add to favorites </a> ");
3
4 // obtain the value from the above in another file
5if (Request. QueryString ["url"]! = Null)
6 {
7 string url = Server. UrlDecode (Request. QueryString ["url"]. ToString ());
8 this.txt Address. Text = url;
9}
10if (Request. QueryString ["title"]! = Null)
11 {
12 string title = Server. UrlDecode (Request. QueryString ["title"]. ToString ());
13 this.txt Title. Text = title;
14}

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.