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

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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! 🙂


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x