title: ASP.NET core, change default redirect for unauthorized
body: <p>I am attempting to redirect to a different login url in ASP.NET MVC6</p>
  
  <p>My account controller login method has a <code>Route</code> attribute to change the url.</p>
  
  <pre><code>[HttpGet]
  [AllowAnonymous]
  [Route("login")]
  public IActionResult Login(string returnUrl = null)
  {
      this.ViewData["ReturnUrl"] = returnUrl;
      return this.View();
  }
  </code></pre>
  
  <blockquote>
    <p>When attempting to access an unathorized page, I am redirected to the invalid url, it should just be <code>/login</code> but instead I get
    <strong><code>http://localhost/Account/Login?ReturnUrl=%2Fhome%2Findex</code></strong></p>
  </blockquote>
  
  <p>I have configured the cookie authentication path as follows:</p>
  
  <pre><code>services.Configure&lt;CookieAuthenticationOptions&gt;(opt =&gt;
  {
      opt.LoginPath = new PathString("/login");
  });
  </code></pre>
  
  <p>I have added a default filter, to ensure that all urls require authentication by default.</p>
  
  <pre><code>services.AddMvc(
      options =&gt;
      {
          options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
      });
  </code></pre>
  
  <p>I have checked that the url <code>/login</code> does in fact load the login page, whilst <code>/account/login</code> does not, as expected.</p>
  
  <p><strong>edit:</strong> I have left the routes as is, (apart from changing the default controller and action)</p>
  
  <pre><code>app.UseMvc(routes =&gt;
  {
      routes.MapRoute(
        name: "default",
        template: "{controller=Site}/{action=Site}/{id?}");
  });
  </code></pre>