Bruno Lopes - 467 - Mar 17, 2014

Is there a way to disable request validation for specific requests in servicestack?

I’m trying to accept HTML in one of the requests, using the following DTO:

    [Route("/post", Verbs = “POST”)]
    public class PublishPost
        public string Title { get; set; }
        public HtmlString Body { get; set; }

But a request fails with HttpRequestValidationException.
An answer in stack overflow at shows a solution that disables for the entire site, but that might be overkill.

Could I turn it off just for requests that include an implementation of  IHtmlString?

The Request Validation is an ASP.NET feature that validates a request before it reaches any ASP.NET HttpHandler, I’m not sure of anyway to disable it per request.

It looks like there may be options in .NET 4.5:

Bruno Lopes:

Thanks for the pointer. A quick check (removing the Body from the DTO and accessing ((HttpRequestBase)Request.OriginalRequest).Unvalidated[“Body”] directly ) still gives me an error, so for now I think I’ll still remove the validation from the entire site.