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 也会出现此异常. 这 ...
随机推荐
- setjmp()和longjmp()函数
之前我们讲到了过程活动记录(AR),那么如何来操纵AR呢,一个可能的方法是,根据局部变量的地址进行推算,例如对于上面的a函数,执行a函数时的当前AR地址就是参数i的地址偏移8个字节,也就是 ((cha ...
- CAD二次开发(02)-添加对象到模型空间
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- PatentTips - Method for network interface sharing among multiple virtual machines
BACKGROUND Many computing systems include a network interface card (NIC) to provide for communicatio ...
- 锐捷SNMp注意:
http://www.ruijie.com.cn/fw/wt/18855 1)设备名称.运行时间.sysOID.设备描述.联系人.设备位置:分别来自RFC-1213-MIB的system组中的sysN ...
- hdoj--2516--取石子游戏(博弈)
取石子游戏 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- poj--1703--Find them, Catch them(并查集巧用)
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64 ...
- php7-swoole-Class 'swoole_websocket_server' not found 问题
标签(空格分隔): php 分析 nginx/apache 读取的php.uini 文件 和 cli模式的php.ini 文件不同导致的 swoole是在cli模式下运行的 或许你安装swoole扩展 ...
- [学习笔记]HTTP协议
转自:www.cnblogs.com/li0803/archive/2008/11/03/1324746.html Author :Jeffrey 引言 HTTP是一个属于应用层的面向对象的协议,由于 ...
- android之软件键盘
不弹出软件键盘 <activity android:name="PresCompleteActivity" android:windowSoftIn ...
- Kafka框架基础
* Kafka框架基础 官网:kafka.apache.org 框架简介 Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.Kaf ...