title: HttpStatusCodeResult(401) returns "302 Found"
body: <p>Using ASP.NET MVC 5, I would like to return appropriate HTTP status code for different scenarios (401 for user is not authenticated, 403 when user has no right for some resource, etc.), than handle them in jQuery.</p>
  
  <p>But the problem is, when I try to return 401, it always returns "302: Found". What is the trick for a custom status code, and why this doesn't work?</p>
  
  <pre><code>public ActionResult My()
  {
      if (User.Identity.IsAuthenticated == false)
      {
          return new HttpStatusCodeResult(401, "User is not authenticated."); 
              // Returns "302: Found"
      }
  
     // ... other code ...
  }
  </code></pre>
  
  <p><strong>EDIT 1: Interesting bit:</strong></p>
  
  <p>If I replace the 401 with a 404 like this:</p>
  
  <pre><code>return new HttpNotFoundResult("User is not authenticated.");
  </code></pre>
  
  <p>Then it indeed gives a 404 and jQuery can catch the problem. However it's not an elegant solution as the error code is different.</p>
  
  <p><strong>EDIT 2:</strong> 302 is not good for me, as the result would be used in <code>jQuery.get().fail()</code>, but 302 won't triger <code>fail()</code></p>