Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL-encode a URL

Is there a .NET encoding method I could use to encode a URL to be passed within a URL parameter?

For example say I have:

url_of_interest = "http://asdf.asdf/asdf.htm"

and I want to include this as one (1) URL form parameter when I do an upload to a web-application:

http://mywebservice/upload?url=<<encoded URL here>>

like image 827
Greg Avatar asked Dec 15 '09 04:12

Greg


2 Answers

System.Web.HttpUtility.UrlEncode

like image 198
ChaosPandion Avatar answered Oct 03 '22 06:10

ChaosPandion


HttpServerUtility.UrlEncode should do the trick:

http://msdn.microsoft.com/en-us/library/zttxte6w.aspx

like image 30
leepowers Avatar answered Oct 03 '22 07:10

leepowers