Remove additional slashes from URL

demo picture demo · May 27, 2015 · Viewed 8.9k times · Source

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?

Answer

Royi Namir picture Royi Namir · May 27, 2015

Use this :

url  = Regex.Replace(url  , @"/+", @"/");

it will support n times

enter image description here