1

How do I properly encode the following url?

http://mysite/myapp/content/Documents/Opening Leave Case for Supervisors-WC&TW.pdf

When I view the url after url encoding the file name I get this error:

"The request filtering module is configured to deny a request that contains a double escape sequence."

I'm certain that the problem lies with the ampersand in the file name but am unsure how to properly deal with it.

Here is what I have so far (that is not working):

string.Concat( "~/Content/Documents/", HttpUtility.UrlEncode( ContentLocation ) );
BeYourOwnGod
  • 2,345
  • 7
  • 30
  • 35

1 Answers1

2

You might try HttpUtility.UrlPathEncode which transforms spaces to "%20" instead of "+". Other than that I see nothing wrong with what you're doing. http://msdn.microsoft.com/en-us/library/system.web.httputility.urlpathencode(v=vs.110).aspx

Also you'll need to post the context of where this error is occurring because the error doesn't occur on the conversion obviously.

Christopher Bales
  • 1,069
  • 1
  • 13
  • 23