title: C# MVC: How to override configured authentication redirect?
body: <p>I have an MVC application with the following block inside in Web.config:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;authentication mode="Forms"&gt;
      &lt;forms loginUrl="~/Login" timeout="2880" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>So, if a user requests a page and authorization fails, they will be redirected to ~/Login.  </p>
  
  <p>That's fine, and I need it for most of my controllers.  However, I have a controller which I'd like to bypass this rule with.  How can I allow specific controllers to ignore this rule?  </p>
  
  <p>My problem is that in my MVC application (which has several controllers), I have a certain controller which hosts a REST interface (not meant for browser use).  Since this controller isn't meant for browser-consumption, I don't want it sending back an entire login page, (or any page whatsoever actually, just strings or partial views.)</p>
  
  <p>Note that I'm using custom [Authorize...] attributes on my actions, and when THESE fail, they redirect to an Error action--but, unfortunately, <em>my Error action (which returns a short string) is being redirected to the Login page</em> because of this configuration setting!  </p>
  
  <p>I'm getting dizzy trying to figure this out, what am I doing wrong? I can provide more details if necessary.</p>