Server.UrlEncode in .ashx

I would like to use Server.UrlEncodein .ashx.

I am trying to use the following code.

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

This is wrong, but nonetheless, I would like to use Server.UrlEncode, so let's find out the way.

+3
source share
1 answer

HttpContext.Current.Server.UrlEncode

... or you can use Uri methods like EscapeDataString , which I prefer because they can even be used outside of ASP.NET.

+10
source

Source: https://habr.com/ru/post/1783342/


All Articles