I created a table “article” with columns articleId and article_content. I also used html editor for “article_content” column. When I tried to save I got the following error. It was resolved by adding [AllowHtml] to article_content property in class.
Don’t forget to include the namespace using System.Web.Mvc.
Problem:
Server Error in '/' Application.
A potentially dangerous Request.Form value was detected from the client (Description="<pre style="font-fam...").
Description: ASP.NET has detected data in the request that is potentially dangerous because it might include HTML markup or script. The data might represent an attempt to compromise the security of your application, such as a cross-site scripting attack. If this type of input is appropriate in your application, you can include code in a web page to explicitly allow it. For more information, see http://go.microsoft.com/fwlink/?LinkID=212874.
Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (Description="<pre style="font-fam...").
Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Solution:
namespace infinetsoft.Areas.Admin.Models
{
using Hammock.Attributes.Validation;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
public partial class Article
{
public int ArticleId { get; set; }
[AllowHtml]
[Required]
public string article_content { get; set; }
}
}
after allowHtml property for the property in the class. I have tried to save it is working fine.