问题
I duplicated an ASP.NET MVC project and renamed all the namespaces to the new project name.
But now, if I log into the original application, and immediately navigate to the duplicated application, the dupe application accepts the authentication cookie and allows me through.
They are hosted on the same domain.
The applications use ASP.NET Identity for authentication.
Is there a unique application key or something like that that needs to be changed in the duplicated application so that it does not accept authentication cookies from the original?
回答1:
Change CookieName in your either application, it will help you. You can find CookieName in:
ASP.NET Identity Change the value of the existing line or add a line to within Startup.Auth.cs
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
/* Add the following line */
CookieName = "MyAppUniqueCookieNameHere"
});
}
}
in case form authentication
<configuration>
<system.web>
<sessionState cookieName="MyAppUniqueCookieNameHere" />
</system.web>
</configuration>
Hope it will help you! :)
来源:https://stackoverflow.com/questions/63316372/how-to-duplicate-an-asp-net-mvc-project-and-make-it-not-accept-authentication-co