How to duplicate an ASP.NET MVC project and make it not accept authentication cookies from the original application?

。_饼干妹妹 提交于 2021-01-29 13:54:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!