Server.UrlEncode、HttpUtility.UrlDecode的区别
Server.UrlEncode、HttpUtility.UrlDecode的区别
输出: 原数据:文件上(传)篇.doc
区别在于:HttpUtility.UrlEncode()默认是以UTF8对URL进行编码,而Server.UrlEncode()则以默认的编码对URL进行编码。
但是, 我们在编写文件下载的页面的时候, 常常用如下方法来指定下载的文件的名称: Response.AddHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlEncode(fileName, Encoding.UTF8)); 之所以转换成 UTF8 是为了支持中文文件名.
上面是从别的地方拷贝的,写得很好,我自己的一个程序中也遇到同样的问题,默认aspx是以utf-8为编码的,在我这个程序中必须用gb2312为默认编码(<globalization requestEncoding="gb2312" responseEncoding="gb2312"/>),问题出现了,以前没有问题的HttpUtility.UrlDecode在Page.Request回的值是乱码这就是上面说的HttpUtility.UrlDecode默认以UTF8对URL进行编码,这种情况下面只需将HttpUtility.UrlDecode改成Server.UrlEncode即可。
Server.UrlEncode、HttpUtility.UrlDecode的区别的更多相关文章
- HttpUtility.UrlEncode 和Server.UrlEncode的区别,记录记录,被乱码搞晕头了。。。。。
今天修改原来的站点,有几个session和cookies乱码问题,然后又好好看了一下关于编码这块的内容. 大概是:登录处,用session记录了一点中文内容.然后cookies也记录了一点中文内容,取 ...
- 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 方法: 对 ...
- Server.UrlEncode与HttpUtility.UrlEncode的区别
一.HttpUtility.UrlEncode 方法 1.public static string UrlEncode(byte[]) 将字节数组转换为已编码的 URL 字符串. 2.public s ...
- 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重写的是说找 ...
- Server.UrlEncode与Server.UrlDecode(url传递中文的解决方案)
1.设置web.config文件.<system.web> ...... <globalization requestEncoding="gb2312" resp ...
- URL传递中文:Server.UrlEncode与Server.UrlDecode
1.设置web.config文件. <system.web> ...... <globalization requestEncoding="gb2312" r ...
- HttpUtility.UrlEncode,Request.RawUrl,HttpUtility.UrlDecode,HttpUtility.UrlPathEncode,Uri.EscapeDataString
碰到同样问题, 记录一下. 引自:https://www.cnblogs.com/ken-admin/p/5826480.html HttpUtility.UrlDecode(url),从Encode ...
随机推荐
- C++ Interview - using new and delete to alloc and free memory
1. dynamic create object and initialization int *pi = new int; // pi points to an uninitialized int ...
- Codeforces Round #306 (Div. 2) E. Brackets in Implications 构造
E. Brackets in Implications Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...
- winForm 程序开发界面参数传递
1. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; u ...
- UVA 10499 (13.08.06)
Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...
- CSS定位规则之BFC 你居然一直不知道的东西!!!!!
相关文档: http://blog.sina.com.cn/s/blog_877284510101jo5d.html http://www.cnblogs.com/dojo-lzz/p/3999013 ...
- Android Studio下载安装使用教程
最近Google的在Google I/O大会上推出了一款新的开发工具android studio.这是一款基于intellij IDE的开发工具,使用Gradle构建,相信做过java的童鞋们都知道这 ...
- 使用 Team Foundation 版本控制命令
使用 Team Foundation 版本控制命令 Visual Studio 2013 其他版本 Visual Studio 2010 Visual Studio 2008 Visual Stu ...
- MYSQL: Handler_read_%参数说明
环境: 表t_feed_idx(user_id bigint, feed_id bigint, KEY (`user_id`,`feed_id`)) engine=innodb;表t_feed_i ...
- tomcat7.0建立新的web服务目录
今天参照网上的配置方法配置了下tomcat的web服务目录,结果总是显示404错误,错误原因是The requested resource is not available.搜索了半天解决方法,终于发 ...
- C# 使用GDI+绘制漂亮的MenuStrip和ContextMenuStrip皮肤
通过上面的效果截图可以看到,重绘后的MenuStrip和ContextMenuStrip可以添加自己的LOGO信息,实现了类似OFFICE2007的菜单显示效果. .NET对菜单控件的绘制提供了一个抽 ...