When posting textbox content which contains html code, I get an error regarding possible dangerous content. I read how to configure the old 2.0 behaviour, but it does not work for me and I would prefer to have a clean solution. I'm probably 开发者_如何学编程not the only person which needs to post html, so I wonder that I could not found a solution for disabling this behaviour. Any hint what's the correct way to solve this problem?
For your input model, you can define:
public class FormViewModel
{
[AllowHtml]
public string Content { get; set; }
}
Where Content
is your appropriate field:
@Html.EditorFor(m => m.Content)
Have you added the Validate Input attribute to the controller method?
[ValidateInput(false)]
I think you only need these in your web.config if using web forms as well as mvc, but might be worth trying.
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
精彩评论