URL编码处理

王朝other·作者佚名  2008-05-30
窄屏简体版  字體: |||超大  

要解决的问题:

将下面的URL作为一个参数传到其他的页面

1 http://domain/de.apx?uid=12&page=15

2 url后面的参数中出现汉字等,如: ....aspx?title=起重机

在出现上面的情况的时候,必须经过一个RUL编码和解码的过程,否则会出现错误.

代码如下:

1//传值

2string temp = " <a href='Add.aspx?url=" +Server.UrlEncode( skin.Page.Request.Url.AbsoluteUri )+ "&title=" +Server.UrlEncode( skin.Page.Header.Title )+ "'>添加到收藏夹</a>");

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 }

http://www.cnblogs.com/waitu/archive/2006/08/15/477123.html

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航