All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET技巧:URL编码处理_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/10 6:27:59 Browse times: 374 Comment times: 0

ASP.NET技巧:URL编码处理_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET技巧:URL编码处理_[Asp.Net教程]

要解决的问题:
将下面的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 }

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.