ASP.NET Login Redirecting to "{appname}_deploy" in Elastic Beanstalk

14 Views Asked by At

I have a .NET 4.6 site, hosted in AWS Elastic Beanstalk and deployed via Azure DevOps release pipeline.

When I attempt to GET an internal page (such as "/Account/Index") while anonymous, the site 301 redirects me (as it should) to the login URL. HOWEVER, the site inserts "{myElasticBeanstalkAppName}_deploy" as the root slug of the URL (https://app.domain.com/myEBSAppName_deploy/Account/Login). The site loads just fine with or without the presence of that myEBSAppName_deploy slug. E.g., https://app.domain.com/Account/Login works just as well. And if I authenticate and then attempt to access the root, I get redirected to "~/Account/Index" just fine as well, without the slug.

I read today that EBS does something with a "_deploy" folder in its hosting, but I didn't really understand, except to say that, "under-the-hood" of EBS, I highly suspect that that's the name of the folder hosting the application.

In my Startup.Auth.cs, I'm specifying Cookie Authentication as follows:

app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.CreateSignInManager);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
  AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
  LoginPath = new PathString("/Account/Login"),
  Provider = new CookieAuthenticationProvider
  {
    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
      validateInterval: TimeSpan.FromMinutes(30),
      regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
  }
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

I assume that the problem relates to my declaration of the LoginPath, but I don't know what I should do differently.

0

There are 0 best solutions below