asp.net Forms Authentication multiple people logge

2019-07-22 02:37发布

问题:

I have a MVC3 website that uses forms authentication, and I wanted to know if there are any issues that may arise if several or more people are logged in using the same user account?

I have been trying to trouble shoot an error we've been having (it looks like the website server is having issues communicating to the database server,) however I just wanted to rule out the possibility of the issue arising from account sharing.

Thanks

回答1:

No, as far as ASP.NET Forms Authentication mechanism is concerned (and I am really talking about Forms Authentication, not ASP.NET Sessions which are 2 completely different things), there are absolutely no issues. Users are tracked with cookies and requests are stateless. Databases also handle concurrency pretty well.

Of course developers could write code that simply doesn't work in this scenario of having multiple users connected with the same account because they did something wrong. For example developers start using ASP.NET Sessions to circumvent the stateless nature of the HTTP protocol. That's where problems might start to arise. For example since ASP.NET Sessions are not thread safe, ASP.NET automatically serializes access to them, meaning that you cannot have concurrent requests from the same session => they are queued and executed sequentially.