user3788671
user3788671

Reputation: 2047

Validation Errors with string contain html tags - MVC

I keep getting an error saying "A potentially dangerous Request.Form value was detected from the client". It is because I have html styling tags within the string which I use to display the string within a text area. I need a way to turn off the validation of this item because it keeps displaying the potentially dangerous page. I have found some other sources but I have not had any success yet.

I have tried:

1.) Adding [ValidationInput(false)] at the top of the Action and I was still getting the potentially harmul page.

2.) Adding the <pages validateRequest="false"></pages> and <httpruntime requestValidationMode = "2.0"></httpruntime>in the Web.config but I was gettting a HTTP Error 500.19 - Internal Server Error. With the error on <pages validateRequest="false"></pages>

Is there any way to get past this error?

Here is my model:

public partial class AP_Tasks
    {
        public int TaskID { get; set; }
        public Nullable<System.DateTime> TaskDate { get; set; }
        public string TaskType { get; set; }
        public string AssignedBy { get; set; }
        public string AssignedTo { get; set; }
        public string CC { get; set; }
        public string Whse { get; set; }
        public string PO { get; set; }
        public string FreightNo { get; set; }
        public string VendName { get; set; }
        public Nullable<System.DateTime> ReqCompDate { get; set; }
        public Nullable<System.DateTime> DueDate { get; set; }
        public Nullable<System.DateTime> CompDate { get; set; }

        public string Notes { get; set; }
        public Nullable<System.DateTime> InvDate { get; set; }
        public Nullable<int> CoNo { get; set; }
        public Nullable<int> NoteCnt { get; set; }
    }

I believe that Notes is the issue. It is the string that containes the HTML tags.

Upvotes: 0

Views: 394

Answers (1)

Jonesopolis
Jonesopolis

Reputation: 25370

Set it on the property level via the [AllowHtml] attribute

Upvotes: 2

Related Questions