Server.UrlEncode与HttpUtility.UrlEncode的区别
一、HttpUtility.UrlEncode 方法
1、public static string UrlEncode(byte[])
将字节数组转换为已编码的 URL 字符串。
2、public static string UrlEncode(string)
对 URL 字符串进行编码。
3、public static string UrlEncode(string, Encoding)
使用指定的编码对象对 URL 字符串进行编码。
4、public static string UrlEncode(byte[], int, int)
从数组中的指定位置开始一直到指定的字节数为止,将字节数组转换为 URL 编码的字符串。
如果在js 传参调用时对应的js编码与解码为
escape unescape
二、Server.UrlEncode方法
1、public string UrlEncode(string)
对字符串进行 URL 编码,并返回已编码的字符串。
2、public void UrlEncode(string, TextWriter)
URL 对字符串进行编码,并将结果输出发送到 TextWriter 输出流。
如果在js 传参调用时对应的js编码与解码为
endcodeURLComponent decodeURLComponent()
三、Server.UrlEncode与HttpUtility.UrlEncode的区别
1、HttpUtility.UrlEncode,HttpUtility.UrlDecode是静态方法,而Server.UrlEncode,Server.UrlDecode是实例方法。
2、Server是HttpServerUtility类的实例,是System.Web.UI.Page的属性。
3、Server.UrlEncode的编码方式是按照本地程序设置的编码方式进行编码的,而HttpUtility.UrlEncode是默认的按照utf-8格式进行编码的,如果需要指定HttpUtility.UrlEncode的编码方式,则需要:HttpUtility.UrlEncode("学习也休闲", Encoding.GetEncoding("gb2312"));
4、两者都会如下转换字符:空格会被转换为加号、非字母数字字符会被转换为他们的十六进制表现形式。
Server.UrlEncode与HttpUtility.UrlEncode的区别的更多相关文章
- Server.UrlEncode、HttpUtility.UrlDecode的区别
Server.UrlEncode.HttpUtility.UrlDecode的区别 在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗? 测试: string file="文件上(传 ...
- HttpUtility.UrlEncode 和Server.UrlEncode的区别,记录记录,被乱码搞晕头了。。。。。
今天修改原来的站点,有几个session和cookies乱码问题,然后又好好看了一下关于编码这块的内容. 大概是:登录处,用session记录了一点中文内容.然后cookies也记录了一点中文内容,取 ...
- HttpUtility.UrlEncode讲解
hello 大家好,今天讲讲HttpUtility.UrlEncode编码 HttpUtility.UrlEncode方法有4个重载分别如下 我们有这么一个字符串 string str = " ...
- HttpUtility.UrlEncode与Server.UrlEncode()转码区别
在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗?测试: string file="文件上(传)篇.doc";string Server_UrlEncode=Server ...
- asp.net URL传递中文参数System.Web.HttpUtility.UrlEncode与Server.UrlEncode的区别
asp.net URL传递中文参数System.Web.HttpUtility.UrlEncode与Server.UrlEncode的区别(一) HttpUtility.UrlEncode 方法: 对 ...
- HttpUtility.UrlEncode,Server.UrlEncode 的区别
引用: 1.HttpUtility.UrlEncode,HttpUtility.UrlDecode是静态方法,而Server.UrlEncode,Server.UrlDecode是实例方法. 2.Se ...
- c#asp.net url 传递中文参数要使用 System.Web.HttpUtility.UrlEncode 而不能使用Server.UrlEncode
最近网站里的参数包括中文的例如: http://www.taiba/Tag%b0%ae%c7%e9.html 已开始使用 Server.UrlEncode来做的,但发现,有一些中文在url重写的是说找 ...
- Owin的URL编码怎么搞?以前都是HttpUtility.UrlEncode之类的,现在连system.web都没了,肿么办?
Owin的URL编码怎么搞?以前都是HttpUtility.UrlEncode之类的,现在连system.web都没了,肿么办? 编码: Uri.EscapeDataString(name) 解码: ...
- asp.net4.0在Global中的Application_Start 中直接或间接使用 HttpUtility.UrlEncode等出现异常Response is not available in this context的解决方法
HttpUtility.HtmlEncode HttpUtility.HtmlDecode HttpUtility.UrlEncode HttpUtility.UrlDecode 也会出现此异常. 这 ...
随机推荐
- Java基础学习总结(4)——对象转型
一.对象转型介绍 对象转型分为两种:一种叫向上转型(父类对象的引用或者叫基类对象的引用指向子类对象,这就是向上转型),另一种叫向下转型.转型的意思是:如把float类型转成int类型,把double类 ...
- 安装spark问题汇总
使用的版本是 spark-1.6.3-bin-without-hadoop 运行spark-shell报错 运行spark-sql报错找不到org.datanucleus.api.jdo.JDOPer ...
- IOS开发-经常使用站点集合
1. https://developer.apple.com //苹果开发人员站点 2. https://itunesconnect.apple.com //itunes站点 3. ...
- oracle树操作(select .. start with .. connect by .. prior)
oracle中的递归查询能够使用:select .. start with .. connect by .. prior 以下将会讲述oracle中树形查询的经常使用方式.仅仅涉及到一张表. star ...
- CSS中的相关概念
CSS的几个概念: 包括块:一个元素的"布局上下文".对于正常的HTML文本流中的一个元素,包括块由近期的块级祖先框.表单元格或行内块祖先框的内容边界(content edge)构 ...
- node05---模块
Node.js开发服务器,数据.路由.本地关心的效果,交互: Node.js实际上是极客开发出的一个小玩具,不是银弹.有着别人不具备的怪异特点: 首先,Node不为每个用户开辟一个线程,所以非常单线程 ...
- asp.net的临时文件夹
https://msdn.microsoft.com/en-us/library/ms366723.aspx Compilation Output When your code is compil ...
- [Project Euler 429] Sum of squares of unitary divisors(数论)
题目链接:https://projecteuler.net/problem=429 题目: 我们称 N 的约数 d 为特殊的当且仅当 gcd(d, n / d) = 1. 设 S(n) 为 n 所有特 ...
- Internet Explorer Developer Channel 自动化测试 IE 浏览器
IE 原生 Web Driver 调用,通过简单配置,即可自动化测试 IE 浏览器(目前仅限 Internet Explorer Developer Channel 版本).做一些自动化的操作,都是很 ...
- Adobe CC update (Windows/Mac OS) 独立升级包下载
Windows 版 xiaogezi.cn Photoshop CC 下载 Download 大小 Size 日期 Date 文档 Notes Adobe Photoshop 14.2.1 Updat ...