To debug my ASP.NET application I created a class called MessageHandling.cs
. At this point it's a singleton pattern but I want it to be an instance per request.
My mssqlDb
class fills the MessagesHandling
class with messages like: 'Db connected', 'Data inserted' and stuff like that. After all the Events of the apsx page are processed the MessageHandling
class is read by createFile.apsx.cs
in the event Page_LoadComplete()
. All the errors and messages will be showm to the user.
At this point the system works for debugging. The problem at this point is that the MessageHandling isn't emptied after the request has been send and the errors are also shown on the second browser without doing anything. I also want to be able to use this system for showing messages to the end users like: "Blog created".
The basic of my problem is the following:
Class A
creates Class B
Class C
reads Class B
The singleton doesn't work because it's not per user / session / request. So I need an other method.
Store it in the HttpContext.Items
, that way it will be for each request.