My web application contains both WebForm page and MVC Views.
In my root web.config i have the following code
<httpRuntime requestValidationMode="2.0" />
And in my web.config for my Views folder i have this code
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.
ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage,
System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
Validation is then turned off on my web form pages but not my MVC Views. I want to turn of request validation for every page so doing it at the controller level is not a solution for me.
Any ideas why this is not working on my MVC Views? The only thing i can find online is to turn the validation mode to 2.0 and set validateRequest to false which i have done.
Try this.
Add ValidateInput
with EnableValidation
to false
in global
filters.
In FilterConfig.cs
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
ValidateInputAttribute noValidate = new ValidateInputAttribute(false);
filters.Add(noValidate);
}