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 也会出现此异常. 这 ...
随机推荐
- Memcached 集群环境Java客户端
Memcached 集群环境Java客户端 学习了: http://blog.csdn.net/zhouzhiwengang/article/details/53154112 http://guazi ...
- POJ 1741 Tree 树的分治(点分治)
题目大意:给出一颗无根树和每条边的权值,求出树上两个点之间距离<=k的点的对数. 思路:树的点分治.利用递归和求树的重心来解决这类问题.由于满足题意的点对一共仅仅有两种: 1.在以该节点的子树中 ...
- Linux 6.3下安装Oracle Enterprise Cloud Control 12c
Oracle enterprise cloud control 12c的安装是一个比較复杂的过程,由于他须要依赖于Oracel database以及Oracle Weblogic. 如今Oracle已 ...
- less04 运算符、命名空间
less //.wp{ // margin: 0 auto; // background: forestgreen; // width: 450px + 450; //有一个有单位就可以 // hei ...
- Android属性动画-Interpolator和ViewPropertyAnimator的用法
Interpolator的用法 Interpolator这个东西很难进行翻译,直译过来的话是补间器的意思,它的主要作用是可以控制动画的变化速率,比如去实现一种非线性运动的动画效果.那么什么叫做非线性运 ...
- html5开发页游(前话)
导师要求模仿某个页游网站开发益智小游戏.老板的要求是要跨平台,IOS,Android.PC.Mac等系统主要通过浏览器打开都能用.那个网站的页游是通过flash实现的,使用这种方法肯定不能满足老板的要 ...
- coedforces #481Div(3)(ABCDEFG)
A. Remove Duplicates Petya has an array aconsisting of nintegers. He wants to remove duplicate (equa ...
- caffe(1) 网络结构层参数详解
prototxt文件是caffe的配置文件,用于保存CNN的网络结构和配置信息.prototxt文件有三种,分别是deploy.prototxt,train_val.prototxt和solver.p ...
- ssh 免交互式登陆
脚本: vim key.sh #!/bin/bash#make key\rm -f /root/.ssh/id_dsassh-keygen -t dsa -f /root/.ssh/id_dsa -P ...
- java开发微信公众号支付(JSAPI)
https://www.cnblogs.com/gopark/p/9394951.html,这篇文章写的已经很详细了. 下面写一下自己的思路: 1.首先下载demo,地址:https://pay.we ...