Skip to main content
added 60 characters in body
Source Link
neontapir
  • 4.8k
  • 3
  • 40
  • 53

The Singleton pattern is used to ensure a single instance of an object is shared across an entire application, so it sounds like the opposite of what you are trying to achieve.

In the latter half of your question, it sounds like you want a separate instance for each request, which is essentially how ASP.NET handles objects by default (read up on Page.Load and Unload on the ASP.NET lifecycle overview page for details). 

If that's the case, you should not need to do anything special except convert this from a static class to a normal class. What behavior are you seeing?

As an aside, you may want to look into Linq for Xml, which is built into the framework and could simplify your XML parsing. With Linq, you could potentially get rid of the need for many of those static variables by using XML queries to retrieve data.

The Singleton pattern is used to ensure a single instance of an object is shared across an entire application, so it sounds like the opposite of what you are trying to achieve.

In the latter half of your question, it sounds like you want a separate instance for each request, which is essentially how ASP.NET handles objects by default (read up on Page.Load and Unload on the ASP.NET lifecycle overview page for details). If that's the case, you should not need to do anything special. What behavior are you seeing?

As an aside, you may want to look into Linq for Xml, which is built into the framework and could simplify your XML parsing. With Linq, you could potentially get rid of the need for many of those static variables by using XML queries to retrieve data.

The Singleton pattern is used to ensure a single instance of an object is shared across an entire application, so it sounds like the opposite of what you are trying to achieve.

In the latter half of your question, it sounds like you want a separate instance for each request, which is essentially how ASP.NET handles objects by default (read up on Page.Load and Unload on the ASP.NET lifecycle overview page for details). 

If that's the case, you should not need to do anything special except convert this from a static class to a normal class. What behavior are you seeing?

As an aside, you may want to look into Linq for Xml, which is built into the framework and could simplify your XML parsing. With Linq, you could potentially get rid of the need for many of those static variables by using XML queries to retrieve data.

Source Link
neontapir
  • 4.8k
  • 3
  • 40
  • 53

The Singleton pattern is used to ensure a single instance of an object is shared across an entire application, so it sounds like the opposite of what you are trying to achieve.

In the latter half of your question, it sounds like you want a separate instance for each request, which is essentially how ASP.NET handles objects by default (read up on Page.Load and Unload on the ASP.NET lifecycle overview page for details). If that's the case, you should not need to do anything special. What behavior are you seeing?

As an aside, you may want to look into Linq for Xml, which is built into the framework and could simplify your XML parsing. With Linq, you could potentially get rid of the need for many of those static variables by using XML queries to retrieve data.