Error 400 (Bad Request) when get a file which name contains & character in C# ASP.NET MVC3 -
i have issue regarding filename contains & character.
i have image name is: test&testagain.jpg. in asp.net mvc3 application, in view side, put
url.content( "~/content/images/"+ filename ); in chrome, see error 400 bad request because of filename contains &.
i think & used query string , browser interprets file name query string.
because filename doesn't contain ? browser throw error. (a potentially dangerous request.path value detected client (&).)
it way (workaround) fix without replace character ?
you need urlencode path:
url.content("~/content/images/" + httpserverutility.urlencode(filename)); edit:
seems doesn't work. way can think of right allow resticted characters , enable verificationcompatibility setting in registry:
// 32-bit iis hklm\software\microsoft\asp.net verificationcompatibility = 1 // 64-bit iis hklm\software\wow6432node\microsoft\asp.net verificationcompatibility = 1
Comments
Post a Comment