Auto login for debugging ASP.NET MVC 5
<p>I've seen </p>

<p><a href="https://stackoverflow.com/questions/1071095/asp-net-forms-authentication-auto-login-with-a-test-account-while-debugging/3265562">ASP.NET forms authentication - auto login with a test account while debugging?</a></p>

<p><a href="https://stackoverflow.com/questions/5966735/asp-net-site-auto-login-during-development">ASP.NET site auto-login during development</a></p>

<p>but that's targeted for older version of ASP.NET MVC (see dates on posts)</p>

<p>I've tried adding </p>

<pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
    if (System.Diagnostics.Debugger.IsAttached &amp;&amp; User == null)
    {
        FormsAuthentication.SetAuthCookie("user1@contoso.com", true);
    }
}
</code></pre>

<p>To global.aspx, but no luck. The login page still triggers. I've tried adding a check in Login, and the page never loads</p>

<pre><code>public ActionResult Login(string returnUrl)
{
    if (System.Diagnostics.Debugger.IsAttached &amp;&amp; User.Identity.IsAuthenticated == false)
    {
        var x = new LoginViewModel() { Email = "user1@contoso.com", Password = "Pa55w0rd!", RememberMe = false };
        Login(x, returnUrl).Wait();
        return View(x);
    }

    ViewBag.ReturnUrl = returnUrl;
    return View();
}
</code></pre>

<p>but when I navigate to a page with requiring authentication, the web page loads indefinitely (if I debug it hits SignInManager.PasswordSignInAsync() and never returns (autogenned code in AccountController).</p>

<p>Any idea what's the way to do this in ASP.NET mvc 5?</p>