I'm having a fairly common issue with ASP.NET MVC 5 where it throws an exception on invalid URL characters, such as &
and %
.
I've tried a lot of different suggestions from other stack overflow questions, like here and here. However, adding this to my Web.config doesn't work:
<system.web>
<httpRuntime requestPathInvalidCharacters="<,>,%,:,\,?"
requestValidationMode="2.0"/>
</system.web>
Nor does adding [HttpValidate(false)]
above my controller methods.
I found this gem while searching for a solution and it looked really promising, but even that doesn't work. The url requests aren't being changed with the code from that site and it makes me wonder if the problem occurs before ASP.net even gets a chance to act.
I'm trying to avoid manually encoding all my requests, but if that's what I have to do then I guess I have no choice.
Here's my stack trace if it helps:
[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (&).]
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9693412 System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +53