Server.UrlEn code&放; Server.UrlDe code [英] Server.UrlEncode & Server.UrlDecode
问题描述
我不知道,为什么我们使用Server.UrlEn code()及Server.UrlDe code()?
在查询字符串,我们看到的网址什么,所以为什么我们要带code或去code呢?
该URLEn code方法应用URL编码规则,包括逃生
字符到指定的字符串。
URLEn code字符转换如下:
空间()被转换为加号(+)。
非字母数字字符转义为它们的十六进制
再presentation。
块引用>另外,我觉得你是在谈论
HttpServerUtility.UrlDe code
方法,去codeS的EN codeD字符串,returnes你回来了原始字符串。
URL德codeS字符串并返回去codeD字符串
URL编码可确保所有浏览器将正确传输文本
URL字符串。字符如问号,连字符(安培)(?),
斜杠(/)和空格可能会被一些被截断或损坏
浏览器。其结果是,这些字符必须是EN $ C $光盘标签或
在查询字符串,其中字符串可以通过浏览器在一个重新发送
请求字符串。
UrlDe code是访问一个便捷的方式HttpUtility.UrlDe code
在方法从ASP.NET应用程序运行时间。在内部,UrlDe code
使用HttpUtility.UrlDe code到德code字符串。
块引用>更多信息...
i dont know, why do we use Server.UrlEncode() & Server.UrlDecode()?! in QueryString we see anything in URL, so why do we want encode or decode them?
解决方案The URLEncode method applies URL encoding rules, including escape characters, to a specified string.
URLEncode converts characters as follows:
Spaces ( ) are converted to plus signs (+).
Non-alphanumeric characters are escaped to their hexadecimal representation.
Also, I think you are talking about
HttpServerUtility.UrlDecode
method which decodes the encoded string and returnes you back the original string.URL-decodes a string and returns the decoded string
URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in tags or in query strings where the strings can be re-sent by a browser in a request string.
UrlDecode is a convenient way to access the HttpUtility.UrlDecode method at run time from an ASP.NET application. Internally, UrlDecode uses HttpUtility.UrlDecode to decode strings.
More info ...
这篇关于Server.UrlEn code&放; Server.UrlDe code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!