找回密码
 注册
搜索
热搜: 回贴

ASP.NET技巧:URL编码处理

2009-12-13 12:49| 发布者: admin| 查看: 55| 评论: 0|原作者: 青鸾峰

▲要解决的问题: 将下面的URL作为一个参......


要解决的问题:
将下面的URL作为一个参数传到其他的页面
1 http://domain/de.apx?uid=12&page=15
2 url后面的参数中出现汉字等,如: ....aspx?title=起重机
在出现上面的情况的时候,必须经过一个RUL编码和解码的过程,否则会出现错误.
代码如下:
1//传值
2string temp = " 添加到收藏夹");
3
4//在另外一个文件中取从上面传的值
5if (Request.QueryString["url"] != null)
6 {
7 string url = Server.UrlDecode(Request.QueryString["url"].ToString());
8 this.txtAddress.Text = url;
9 }
10 if (Request.QueryString["title"] != null)
11 {
12 string title = Server.UrlDecode(Request.QueryString["title"].ToString());
13 this.txtTitle.Text = title;
14 }

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 03:33 , Processed in 0.130517 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部