打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
在C#中使用server.UrlEncode() 方法
今天的蛛蛛 遇到的问题就是windows service 中没有办法用asp.net中Server.UrlEncode() 的方法 url没有办法转码 这个纠结啊!
办法如下: 尝试通过
控制台或Winform程序中如何编码或解码Server.URLEncode
2010年07月10日 星期六 23:03
在Asp.net中可以使用Server.HTMLEncode和Server.URLEncode 将文本或URL的特殊字符编码,
但在控制台或Winform程序中没有办法使用到这些方法,

解决办法:

右击项目==》添加引用==》.NET==》System.Web==》确定

System.Web.HttpUtility.HtmlEncode(str);
System.Web.HttpUtility.HtmlDecode(str);

System.Web.HttpUtility.UrlEncode(str);

System.Web.HttpUtility.UrlDecode(str);




编码后得到的字串和用Server.URLEncode编码得到的不一样,那边接收到的也是乱码??

编码时可以指定编码的,如
System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.Unicode);
System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.UTF8);
System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding( "GB2312 "));


解码也可以指定编码的
System.Web.HttpUtility.UrlDecode(str,System.Text.Encoding.Unicode);
System.Web.HttpUtility.UrlDecode(str,System.Text.Encoding.UTF8);
System.Web.HttpUtility.UrlDecode(str,System.Text.Encoding.GetEncoding( "GB2312 "));
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
asp及asp.net的urlencode问题
URL中包含中文参数造成乱码的解决之道
mvc存储Cookie和读取Cookie方法
c# .net url带中文参数显示乱码的问题
各种语言中的urlencode方法
你不知道的 页面编码,浏览器选择编码,get,post各种乱码由来
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服