user576510
user576510

Reputation: 5905

Is Singleton in asp.net session specific or one for all sessions?

I am wondering, is a singleton in asp.net session specific or is it shared between all user sessions?

Also does it remain alive until application is restarted, when a user session ends or when garbage collecting starts and clears memory from it as well.

Your input is highly appreciated.

Upvotes: 2

Views: 367

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500495

A traditional singleton - with a reference in a static variable - will live for as long as the AppDomain lives. It will not be session-oriented. It will be garbage collected when the AppDomain is recycled (or the app is shut down).

Upvotes: 4

Related Questions