Can't get past "A potentially dangerous Request.Form value was detected..." error
Posted
by joshb
on Stack Overflow
See other posts from Stack Overflow
or by joshb
Published on 2010-04-17T22:27:09Z
Indexed on
2010/04/17
22:33 UTC
Read the original article
Hit count: 474
asp.net-mvc
I'm doing my first ASP.NET MVC2 project and I can't get past the "A potentially dangerous Request.Form value was detected..." error when trying to submit a form. I've done this in MVC1 using the ValidateInputAttribute and I've read about the breaking change in .NET 4 that requires setting the request validation mode in the web.config. Basically I'm doing exactly what is outlined in this thread: http://stackoverflow.com/questions/2019843/a-potentially-dangerous-request-form-value-in-mvc-2-asp-net-4-0.
Nothing's working though so I must be missing something. Here's my code:
Web.config
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<httpRuntime requestValidationMode="2.0" />
<pages
validateRequest="true"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
Controller action
[AcceptVerbs(HttpVerbs.Post)]
[ValidateInput(false)]
public ActionResult Edit(Page pageToEdit)
{
// do stuff....
}
Any ideas on what I'm doing wrong here?
© Stack Overflow or respective owner