在C#中使用server.UrlEncode() 方法
来源:互联网 发布:手机淘宝淘部落 编辑:程序博客网 时间:2024/05/22 04:40
今天的蛛蛛 遇到的问题就是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 "));
但在控制台或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 "));
- 在C#中使用server.UrlEncode() 方法
- 在C#中使用server.UrlEncode() 方法
- C# winform及.net 中使用 Server.URLEncode
- 在SQL Server 2005中实现 Server.UrlEncode、Server.UrlDecode
- Server.UrlEncode方法在IE浏览器中文参数提交中的使用
- 在 ASP 中创建返回页面链接及 server.URLEncode 的使用
- python中urlencode方法
- Server.UrlEncode和Server.UrlDecode的使用
- Server.UrlEncode和Server.UrlDecode的使用
- 在C#中使用扩展方法
- Server.UrlEncode
- Server.UrlEncode与HttpUtility.UrlDecode使用
- 如何在C#中使用存储过程(SQL Server 2000)
- C#中Winform如何获取HTTPUtility.UrlEncode
- VB中实现ASP中Server.URLEncode与Server.URLDecode
- Server.UrlEncode 与 HttpUtility.UrlEncode
- 关于HttpUtility.UrlEncode,Server.UrlEncode
- ASP.NET中使用Server.Transfer()方法在页间传值
- 圣诞节
- Java中找到每月第一天、最后一天的方法
- SQL Server是如何判断Status状态位的?
- Tslib Manual Calibrate On Android
- Visual Studio 2010 Team System 动手实验室
- 在C#中使用server.UrlEncode() 方法
- myEclipse debug android 'hello world'
- zz迅雷7无法自动登录解决办法
- Gridview操作集锦
- SQL Server 2008 筛选器报错
- JSF Gossip: Backing Beans
- vc中调用其他应用程序的方法(函数) winexec,shellexecute ,createprocess
- 使用UIPopupViewController
- Truncate、Drop 和 Delete的异同