kst
kst

Reputation: 1518

Server.UrlEncode in .ashx

I would like to use Server.UrlEncode in .ashx.

I try with the following code.

HttpServerUtility ser = new HttpServerUtility();
ser.UrlEncode(pfile.FileName);

That's wrong but however I would like to use Server.UrlEncode so let know the way.

Upvotes: 3

Views: 2498

Answers (1)

Josh
Josh

Reputation: 69262

HttpContext.Current.Server.UrlEncode

... or you can use the methods of Uri such as EscapeDataString which I tend to prefer because of the fact that they can be used even outside of ASP.NET.

Upvotes: 10

Related Questions