Maxim V. Pavlov
Maxim V. Pavlov

Reputation: 10509

Localhost cookies in ASP.NET debugging environment

I am working on several asp.net sites simultaniously. All of them use cookie-based (out of the box) authentication mechnism. When a web site on localhost:4587 was being bedduged in VS I have logged in as an "admin" user and did some testing.

The next day I am opening different project for debugging that runs on localhost. And when I attempt to access the MVC controller action that is marked with Authorization atribute, the system assumes the current user is "admin" and is looking for it's roles based on a custom provider. But on this site, there isn't even a user named "admin". How can I make sure cookies from other sites don't make it to Role check in ASP.NET MVC application?

Upvotes: 1

Views: 1450

Answers (2)

Serj Sagan
Serj Sagan

Reputation: 30247

Give your forms tag a unique name in each application

<authentication mode="Forms">
  <forms name="myVeryUniqueNameForApp1" />
</authentication>

<authentication mode="Forms">
  <forms name="myCompletelyUniqueNameForApp2" />
</authentication>

Upvotes: 1

esjr
esjr

Reputation: 186

I would suggest it is always a good practice to delete all localhost cookies after testing. As explained here : asp.net cookies, authentication and session timeouts , you can also add details to the authentication cookie to ensure it is discarded after a session, ie when you close the browser or to differentiate between two sites. Another approach to avoid cookies 'clashing' is to use two different browsers : Chrome for the one and a Comodo Dragon or Chromium for the other.

Upvotes: 1

Related Questions