How to encode url string to eliminate spaces ?

  • Thread starter Thread starter Aahz
  • Start date Start date
A

Aahz

Hello,

In my asp.net application I need to get url to string like this:
str = Request.Url.AbsoluteUri;
Problem is with url'a that have spaces like: http://www.site.com/dial
the number.aspx
I heard about EncodeUrl method but I dont know how to use it.

I tried: str = EncodeUrl(Request.Url.AbsoluteUri); , but thats not it

Any help? Thank you
 
Aahz said:
Hello,

In my asp.net application I need to get url to string like this:
str = Request.Url.AbsoluteUri;
Problem is with url'a that have spaces like: http://www.site.com/dial
the number.aspx
I heard about EncodeUrl method but I dont know how to use it.

I tried: str = EncodeUrl(Request.Url.AbsoluteUri); , but thats not it

Any help? Thank you

Hi,
If you want to get rid of "%20" in an url you need to decode an url
instead of encoding it:
string s = Server.UrlDecode(Request.Url.AbsoluteUri);
 
Back
Top