3

I am using UrlRewritingNet.UrlRewriter.dll for url rewriting purpose and frankly, I am new to this stuff. My problem is that , i want to replace %20 in my url with -.

1
  • Why would you want to do this? Commented Nov 29, 2011 at 15:23

3 Answers 3

5

HttpUtility.UrlDecode() does what you need.

Sign up to request clarification or add additional context in comments.

2 Comments

If i am right then in my aspx page , you want to say this <%#string.Format(~/Mypage/{0},HttpUtility.UrlDecode(Eval("MyNamewithSpaces")))%> .... is it???????????
That would turn %20 into a space. The questioner is trying to turn them into - (dash).
2

If you need a custom replace apart that HttpUtility gives you (in this case it will convert it to space!) then just use string replacement.

Uri myuri = new Uri(myolduri.ToString().Replace("%20","-"));

1 Comment

Wrap this transformation into a helper method and use it for binding.
0

or you can put the url in a string then use

string urla = "your url";
string urlb = url.Replace("%20", "-");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.