title: Use HttpRequest in validation context
body: <p>in .net Framework &lt;= 4.7.2, in validation context, you could get the current <code>HttpRequest</code> by accessing the <code>HttpContext</code>.</p>
  
  <p>For example, I had a piece of code which looked like this:</p>
  
  <pre><code>public sealed class AccessValidator : ValidationAttribute
  {
      protected override ValidationResult IsValid(object value, ValidationContext context)
      {
          // validate stuff, if all true -&gt; yield ok.
  
          // if is not valid
          var request = HttpContext.Current.Request;
  
          // store/log the request payload.
      }
  
  }
  </code></pre>
  
  <p>This cannot be done when using .net Core 2.1. 
  I saw a post regarding injection of <code>IHttpContextAccessor</code> or something, but it exposes the request in almost every place.</p>
  
  <p>Since this is an external library to my server, I wish it not rely on server code injections because then it creates a dependence I don't want to be.</p>
  
  <p>Is there any known way to handle this or around this?</p>