title: ASP.Net RequestValidation for json POST to match Form RequestValidation
body: <p>I want to be able to do RequestValidation on content-type "application/json" in a consistent manner to Form validation ("application/x-www-form-urlencoded").</p>
  
  <p>I've read <a href="https://msdn.microsoft.com/en-us/library/system.web.util.requestvalidator(v=vs.110).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/system.web.util.requestvalidator(v=vs.110).aspx</a> but it hasn't been too much help.</p>
  
  <p>I'm looking at trying to implement a custom request validator to replace the default System.Web.Util.RequestValidator.</p>
  
  <p>I've also looked at <a href="https://msdn.microsoft.com/en-us/library/system.web.util.requestvalidator(v=vs.110).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/system.web.util.requestvalidator(v=vs.110).aspx</a></p>
  
  <p>If I can't get the input to be consistently validated I will probably remove the ability to send json to the controllers and force everything through forms - not ideal as I'd like some methods to accept json.</p>
  
  <p>I already encode the output (where possible) but I still want defense in depth by validating the input and ideally consistently for forms and json.</p>
  
  <p>Unfortunately a lot of the MSDN docs on this are heavily out of date and now irrelevant.</p>
  
  <p>I'm using .net 4.6.1 for reference.</p>
  
  <p>Is it sensible to try and validate requests in this manner?</p>