一、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的区别的更多相关文章

  1. Server.UrlEncode、HttpUtility.UrlDecode的区别

    Server.UrlEncode.HttpUtility.UrlDecode的区别 在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗? 测试: string file="文件上(传 ...

  2. HttpUtility.UrlEncode 和Server.UrlEncode的区别,记录记录,被乱码搞晕头了。。。。。

    今天修改原来的站点,有几个session和cookies乱码问题,然后又好好看了一下关于编码这块的内容. 大概是:登录处,用session记录了一点中文内容.然后cookies也记录了一点中文内容,取 ...

  3. HttpUtility.UrlEncode讲解

    hello 大家好,今天讲讲HttpUtility.UrlEncode编码 HttpUtility.UrlEncode方法有4个重载分别如下 我们有这么一个字符串 string str = " ...

  4. HttpUtility.UrlEncode与Server.UrlEncode()转码区别

    在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗?测试: string file="文件上(传)篇.doc";string Server_UrlEncode=Server ...

  5. asp.net URL传递中文参数System.Web.HttpUtility.UrlEncode与Server.UrlEncode的区别

    asp.net URL传递中文参数System.Web.HttpUtility.UrlEncode与Server.UrlEncode的区别(一) HttpUtility.UrlEncode 方法: 对 ...

  6. HttpUtility.UrlEncode,Server.UrlEncode 的区别

    引用: 1.HttpUtility.UrlEncode,HttpUtility.UrlDecode是静态方法,而Server.UrlEncode,Server.UrlDecode是实例方法. 2.Se ...

  7. c#asp.net url 传递中文参数要使用 System.Web.HttpUtility.UrlEncode 而不能使用Server.UrlEncode

    最近网站里的参数包括中文的例如: http://www.taiba/Tag%b0%ae%c7%e9.html 已开始使用 Server.UrlEncode来做的,但发现,有一些中文在url重写的是说找 ...

  8. Owin的URL编码怎么搞?以前都是HttpUtility.UrlEncode之类的,现在连system.web都没了,肿么办?

    Owin的URL编码怎么搞?以前都是HttpUtility.UrlEncode之类的,现在连system.web都没了,肿么办? 编码: Uri.EscapeDataString(name) 解码: ...

  9. asp.net4.0在Global中的Application_Start 中直接或间接使用 HttpUtility.UrlEncode等出现异常Response is not available in this context的解决方法

    HttpUtility.HtmlEncode HttpUtility.HtmlDecode HttpUtility.UrlEncode HttpUtility.UrlDecode 也会出现此异常. 这 ...

随机推荐

  1. 洛谷—— P2701 [USACO5.3]巨大的牛棚Big Barn

    https://www.luogu.org/problem/show?pid=2701 题目背景 (USACO 5.3.4) 题目描述 农夫约翰想要在他的正方形农场上建造一座正方形大牛棚.他讨厌在他的 ...

  2. 文件共享服务器nfs搭建过程

    网络文件共享服务器192. yum install -y nfs-utils 在exports文件中添加的从机范围 vim /etc/exports /home/nfs/ (rw,sync,fsid= ...

  3. 17.查找效率最高的unorderd_set(替代hash_set)

    #include <string> #include <iostream> //查询性能最高(不允许重复数据) #include <unordered_set> u ...

  4. Spring Boot AutoConfiguration注解@ConditionalXXXX之前生今世

    1.注解@Conditional的定义 @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHO ...

  5. RSA加密的方式和解密方式

    RSAsecurity.java package com.mstf.rsa; import java.security.KeyFactory; import java.security.KeyPair ...

  6. form表单加密前台js后台java

    1.前台javascript 1.在提交的js中这样写 <!-- 加密解密 --> document.form1.username.value=encode64(document.form ...

  7. CentOS6.9下ssh密钥登录配置步骤(免密码登录)和ssh-keygen 命令常用参数

    密钥登录步骤(免密码登录)ssh登录提供两种认证方式:口令(密码)认证方式和密钥认证方式.其中口令(密码)认证方式是我们最常用的一种,出于安全方面的考虑,介绍密钥认证方式登录到linux/unix的方 ...

  8. [USACO16FEB]围栏Fenced In Platinum

    题目:洛谷P3141. 题目大意:有一个方形区域,被分成若干区域.现在要去掉若干条围栏,使得所有区域连通,求最少去掉多少长度的围栏. 解题思路:贪心.建议画图思考. 先对围栏位置进行排序,然后相邻两条 ...

  9. 用Python爬取影视网站,直接解析播放地址。

    记录时刻! 写这个爬虫主要是想让自己的爬虫实用,把脚本放到了服务器,成为可随时调用的接口. 思路算是没思路吧!把影视名带上去请求影视网站,然后解析出我们需要的播放地址. 我也把自己的接口分享出来.接口 ...

  10. Python爬虫基础示例

    使用pip安装相关依赖: pip install requests pip install bs4 安装成功提示:Successfully installed *... 爬取中国天气网数据示例代码: ...