卸下URL附加斜杠 [英] Remove additional slashes from URL
本文介绍了卸下URL附加斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 ASP.Net
是更多钞票被像网址,直逼网页获得同样的内容本地主机:9000 /的Index.aspx
和本地主机:9000 // Index.aspx的
甚至本地主机:9000 ///的Index.aspx
In ASP.Net
it is posible to get same content from almost equal pages by URLs like
localhost:9000/Index.aspx
and localhost:9000//Index.aspx
or even localhost:9000///Index.aspx
但它不适合我看起来不错。
But it isn't looks good for me.
如何用户去一些页面,在什么地方之前,我删除此额外的斜线?
How can i remove this additional slashes before user go to some page and in what place?
推荐答案
这解决方案是不是pretty但很容易
This solution is not that pretty but very easy
do
{
url = url.Replace("//", "/");
}
while(url.Contains("//"));
这将在您的网址很多斜线工作,但运行时是不是很大。
This will work for many slashes in your url but the runtime is not that great.
这篇关于卸下URL附加斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文