Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ASP.Net Identity on multiple web applications

I've got several applications hosted on the same IIS (different context roots), that are all protected using the Microsoft.ASPNet.Identity 2.1 NuGet packages. At the moment however, when I log in to one of the applications, the next visit to any of the other applications prompts me to log in again. I can't be logged in to more than just one of the applications at once.

I'm guessing that they are all using the same cookie to store the login token, so when you log in on one app, it resets the cookie which becomes invalid for requests to the other applications.

What are my options for resolving this? I don't mind having to log in to each app individually, so can each app be configured to use a different cookie?

Alternatively, each app does in fact share the same User table in the DB, so it might be possible to configure it so that when you log in to one of the applications, the others also become logged in.

like image 375
Simon Green Avatar asked Jun 23 '15 09:06

Simon Green


1 Answers

Have a different cookie name for each app:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    CookieName = "CookieNameHere",
});

As shown on this page http://tech.trailmax.info/2014/07/rename-authentication-cookie-name-of-asp-net-identity/

like image 110
Luke Avatar answered Sep 18 '22 06:09

Luke