According to this link, now we can use Request.Unvalidated to access a raw value of a form field wihout triggering request validation (and see dreadful error message A potentially dangerous Request.Form...). Unfortunately I could not get it work.
Web.config
<httpRuntime targetFramework="4.5" requestValidationMode="4.5" />
A simple field in view model:
// [AllowHtml] - even I tried this, it still did not work :(
public string Description { get; set; }
And controller action:
[HttpPost]
public ActionResult Edit([Bind(Prefix = "Edit")] EditModel model)
{
string s = Request.Unvalidated.Form["Edit.Description"];
}
I still see error "A potentially dangerous Request.Form...", why? Tried google but there was no example with ASP.NET MVC.
Toolbox: I'm working with a ASP.NET MVC 4 project, targetting .NET 4.5, and VS2012.
Thanks,
UPDATE: Using AllowHtml with Description property fixed my problem, even don't need Request.Unvalidated. There is still an issue as I commented below in @webdeveloper's answer.
Look at this links:
They will help you to understand, how does it works.
It looks like you need to set the request validation mode to 2.0 as described in webdeveloper's first link. Try this:
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With