Can someone please provide scenarios where Singleton Pattern can be used to store commonly used data in Asp.net application, which is expensive to retrieve on each request ? Also, is it better to use Application State for the same? Also, can Singleton Pattern be used to store Web.Config settings when the application is started ?
Asked
Active
Viewed 3,312 times
0
-
This fascination with patterns... anyway, [this SO question](http://stackoverflow.com/questions/86582/singleton-how-should-it-be-used) might help you. As for one of the details of your question - web.config values are already cached, you don't need any extraneous extra technology around it. – J. Steen Nov 11 '12 at 09:41
-
Duplicate of http://stackoverflow.com/questions/303725/asp-net-application-state-vs-a-static-object – Wiktor Zychla Nov 11 '12 at 09:48
1 Answers
0
I think there is no simple way of using Singleton pattern in ASP.Net ,I would prefer wrapping session state object in a static class,since a session is one for the entire application (but different for every user).
Application state is already kind of Singleton in the sense it's one for every use and entire application.
I would not prefer to store Web.Config anywhere else you can make a wrapper class for it if you like.
Some Related Post:
Asp.net cache singleton pattern
Asp.net singleton pattern scenario
Singleton pattern Asp.net csharp for each user

Community
- 1
- 1

DayTimeCoder
- 4,294
- 5
- 38
- 61
-
@J.Steen You are right that's what I intended to mean by different browser ,let me clarify my post – DayTimeCoder Nov 11 '12 at 09:43