Httputility. urlencode method:
Encode the URL string to implement reliable HTTP transmission from the Web server to the client.
Reload listConverts byte arrays to encoded URL strings for reliable HTTP transmission from the Web server to the
Notes:1. httputility. urlencode and httputility. urldecode are static methods, while server. urlencode and server. urldecode are instance methods.2. Server is an instance of the httpserverutility class and a property of system. Web. UI. Page.3.
Parameters on the latest website include Chinese characters, for example:
Http://www.chinapoesy.com/Tag%b0% AE %c7%e9.html
Server. urlencode has already been used. However, some Chinese characters cannot be found in URL rewriting, so there is no
Parameters on the latest website include Chinese characters, for example:
Http://www.chinapoesy.com/Tag%b0% AE %c7%e9.html
Server. urlencode has already been used. However, some Chinese characters cannot be found in URL rewriting, so there is no
Today, I am working on a small program to find that the encoding produced by the C # system. Web. httputility. urlencode function is different from that we normally use, for example:
The encoding produced by using system. Web. httputility.
Server. urlencode MethodThe URL encoding rules will be applied to a string, including escape characters.
Urlencode converts the following characters:
Space () is converted to the plus sign (+)
Non-alphanumeric characters are converted to their
Chaotic URI Encoding
There are three methods for encoding in javascript: escape, encodeuri, encodeuricomponent
C # encoding methods: httputility. urlencode, server. urlencode, Uri. escapeuristring, Uri. escapedatastring
The javascript code is okay.
This article uses three examples to introduce the usage of HttpWebRequest post in asp.net and the convenience methods in various places. If you need it, you can refer to this article.
First look at a simple measure
The Code is as follows:
First look at a simple measure The code is as follows:Copy code Using System;Using System. IO;Using System. Collections;Using System. Data;Using System. Linq;Using System. Web;Using System. Web. Services;Using System. Web. Services.
In the HTTP protocol, the following parameters are transmitted to the server: HTTP header/get String/post body
The following example
Code Demonstrate how to simply post data to the server.
//
Send request
String
Requestbody
=
There are generally three solutions:
1. Set the web. config file
............
2. Before passing Chinese characters, encode the Chinese parameters to be passed and decode them upon receiving them.> Transfer
String Name = "Chinese parameter ";Response.
ASP. NET In
URL Encoding Decoding
Today, the project needs to post data to the ASP Client URL, but the URL Chinese cannot be used. In the afternoon, ASP andAsp.netOfURL EncodingDifferent things:
Let's take a look at the following two URLs. Are
C # Use System. Web. httputility. urlencode instead of server. urlencode to pass Chinese parameters in Asp.net URL.
Parameters on the latest website include Chinese characters, for example:
Http://www.chinapoesy.com/Tag%b0% AE %c7%e9.html
Server.
Today, eggplant _ 2008 gave feedback on "C ++" in his blog"The tag is invalid. After checking the code, httputility. urlencode (URL) is used to generate the link, andHttputility. urldecode (URL), from encode to decode, "C ++" is changed to "C"(The
Call a download program today. When the downloaded URL contains Chinese characters, it cannot be downloaded, for example:
Http://www.huachu.com.cn/itbook/booklist.asp? Tsmc = assembly
I will use the Server. UrlEncode function in. net for conversion.
CookiecontainerHasBugOnHandling DomainName hereHttps://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx? Feedbackid = 478521And Microsoft decided notFixIt In. NET 2.0/3.0/3.5.
I want to inspect the problem and want to do my own hack
I. Passing parameters in Javascript
$ ("# Content"). Load ("default. aspx? Id = "+ IDs +" # P-getting-started # Content ")
If the IDS string contains no spaces but spaces in the middle, the page receiving parameters are not accurate and garbled.
The following is reproduced from:
Http://hi.baidu.com/yisqiu/blog/item/e0804bfb9243fb67024f5624.html
Which one should I use for URL encoding? Are there any differences between these two methods?Test:String file = "file (upload document .doc
Chaotic URI Encoding
There are three methods for encoding in JavaScript: escape, encodeURI, encodeURIComponent
C # encoding methods: HttpUtility. UrlEncode, Server. UrlEncode, Uri. EscapeUriString, Uri. EscapeDataString
The JavaScript code is okay.
The same server. urlencode has different encoded characters on different pages. Later, I checked the original characters ..
Which one should I use for URL encoding? Are there any differences between these two methods?Test:String file = "file
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.