I dont understand how asp.net mvc maintains the users state. I took a very simple mvc4 template and logged in with google, yahoo and other registered clients, no login changed my url ,it always remained the same like
http://localhost:180xx/
how to differentiate between two users?
how to differentiate between two users?
It uses Forms Authentication
which basically stores the currently authenticated user in a cookie which is sent on each request.
The way Forms Authentication works is that when you (or a public identity provider if you are using OAuth) successfully verifies the credentials of the user, your application emits a forms authentication cookie to the client browser. This cookie contains the encrypted usermame. The cookie is then sent on each request and the so called Forms Authentication HTTP module (which runs before all requests) reads this cookie, decrypts it and sets the HttpContext.User
property which you could use in your code to identify the currently authenticated user:
public ActionResult SomeAction()
{
var user = this.User;
// you may use the user.Identity here
...
}