Tuesday, September 16, 2014

Singleton in ASP.NET web application

Question: One part of the web application is designed using singleton pattern. So across all users this object will be one. Is it correct?

Answer: Yes. There will be only one instance.

Each request to an asp.net site comes in and is processed on it's own thread. But each of those threads belong to the same application. That means anything you mark as static is shared across all requests, and therefore also all sessions and users.