i getting this error when inserting a record with "<".
how to solve this error with inserting a string with "<" in it. im using entity framework. this column has a datatype of nvarchar.
thanks in advance.
i getting this error when inserting a record with "<".
how to solve this error with inserting a string with "<" in it. im using entity framework. this column has a datatype of nvarchar.
thanks in advance.
You could try setting the attribute requestValidationMode="2.0"
on the <httpRuntime />
element in web.config
<system.web>
...
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
...
</system.web>
And decorate your controller/action (choose the apropriate one) with:
[HttpPost]
[ValidateInput(false)]
public ActionResult MyMethod(string s)
{
....
}
Note: Always sanitize your input.
Apart from what @scheien already suggested you could check if you are setting the input (with potentialy dangerous script i.e. < character) to some model value that does not accept it. Try doing this:
[AllowHtml]
public string text{ get; set;}