如何从URL中删除%20之类的特殊字符? [英] How I can remove special character like %20 from URL?

查看:654
本文介绍了如何从URL中删除%20之类的特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用ASP.net和C#。

我想从网址中删除%20之类的特殊字符。

对于URL重写,我使用了Global.asax。

请帮帮我。

示例网址

localhost:24882 / WebSite2 / ProductList / 396 / Micromax%20Ninja%20A89

i只需要

http:// localhost:24882 / WebSite2 / ProductList / 396 / Micromax_Ninja_A89。





如果您知道任何其他URL重写方法,请告诉我

I have used ASP.net with C#.
I want to remove special character like %20 from url.
For URL Rewritting i have used Global.asax.
Please help me out with this.
sample url
localhost:24882/WebSite2/ProductList/396/Micromax%20Ninja%20A89
i want only
http://localhost:24882/WebSite2/ProductList/396/Micromax_Ninja_A89.


If you know any other method to URL Rewritting then let me know

推荐答案

http://forums.asp.net/t/1214422.aspx [ ^ ]


链接


您好,



您可以使用



Hi,

You can use

// FOR URL ENCODE
string destinationURL = "http://localhost:24882/WebSite2/ProductList/396/Micromax_Ninja_A89";
HttpContext.Current.Server.UrlEncode(destinationURL);

// FOR URL DECODE
string url = "localhost:24882/WebSite2/ProductList/396/Micromax%20Ninja%20A89";
HttpContext.Current.Server.UrlDecode(url);





注意:(在url%20中用于单个空白空间不是下划线)



还有一件事你真正需要的东西,因为在URL重写中,我认为(就像我使用的那样)不需要URL编码/解码你需要......



还有一件事从未在你发布的问题中回答,如果您有任何疑问,请发表评论..



谢谢

ASP.NET BLOG - hemant [ ^ ]


这篇关于如何从URL中删除%20之类的特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆