title: Modify CookieAuthenticationOptions LoginPath OnRedirectToReturnUrl Event
body: <p>I have the following setup in my MVC 6 ASP.NET 5 project:</p>
  
  <p>Startup.cs in the Configure Method:</p>
  
  <pre><code>app.UseCookieAuthentication(options =&gt;
  {
      options.AuthenticationScheme = "Cookie";
      options.LoginPath = new PathString("/&lt;TENANT&gt;/account/signin/");
      options.AccessDeniedPath = new PathString("/&lt;TENANT&gt;/account/unauthorised/");
      options.AutomaticAuthenticate = true;
      options.AutomaticChallenge = true;
      options.Events = new CookieAuthenticationEvents
      {
          OnRedirectToReturnUrl = MyClass.RedirectToReturnUrlAsync
      };
  });
  </code></pre>
  
  <p>Events class:</p>
  
  <pre><code>public static class MyClass
  {
      public static async Task RedirectToReturnUrlAsync(CookieRedirectContext context)
      {
          context.Options.LoginPath = new PathString("/&lt;HERE I PLAN TO PUT LOGIC TO FIGURE OUT TENANT FROM CONTEXT&gt;/account/signin");
      }
  
  }
  </code></pre>
  
  <p>Lets say a user goes to the following url:</p>
  
  <pre><code>http://localhost/mycompany/securecontroller/secureaction
  </code></pre>
  
  <p>I want the Cookie middleware to redirect the user to:</p>
  
  <pre><code>http://localhost/mycompany/account/signin
  </code></pre>
  
  <p>The problem is the code "MyClass.RedirectToReturnUrlAsync" never gets hit when a Redirect to Return Url happens, so I cannot find the opportunity to modify the LoginPath at runtime.</p>
  
  <p>I suspect I have something wrong in my setup. Has anybody ever encountered this problem?</p>
  
  <p>Hooroo</p>