I need to create a web api that accepts a multipart form request that contains input for text, file fields. Now I'm facing a problem that I cannot send html text through the text field.
[HttpPost]
public HttpResponseMessage SampleController()
{
try
{
var httpRequest = HttpContext.Current.Request;
var sendItem = httpRequest.Params["Body"];
}
}
The code above shows the api controller. It accepts a 'Body' field that contains Html contents. When parsing the request by controller caught an Error shown below.
System.Web.HttpRequestValidationException: 'A potentially dangerous Request.Form value was detected from the client (
Body="<p><b>Hai</b></p>"
).
Web.config:
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
</system.web>
How to solve this issue so that it can accept text with html?