Hannoun Yassir
Hannoun Yassir

Reputation: 21202

how to create a singleton asmx service

how can i create an singleton asmx webservice ? (please don't say use WCF and WWF :D )

Upvotes: 1

Views: 1307

Answers (5)

John Saunders
John Saunders

Reputation: 161781

I won't suggest WCF, but only because you asked us nicely not to.

I will mention that you've found yet another reason to use WCF over ASMX. You might want to keep a list.

You might also want to keep a list of reasons to use ASMX over WCF. You might even want to use the same list for the reasons not to upgrade to .NET 3.5 SP1. It won't be a long list.

There may come a time, when Management wonders why certain things take so long to accomplish, when you'll want to send them your list.

Upvotes: 3

Rich Rodriguez
Rich Rodriguez

Reputation: 126

I'm not sure how a singleton solves your performance problem, unless you are caching data inside the instance. In that case, I'd agree with the above suggestion of introducing the cache between the service and the database. Just how mutable is this data?

Upvotes: 3

Steven Sudit
Steven Sudit

Reputation: 19620

Depending on what you want to do, maybe you can write the engine as a singleton that's accessed by whatever thread services the ASMX call.

Upvotes: 1

Axl
Axl

Reputation: 8502

You could use an ashx (HttpHandler). Implement IHttpHandler and set IsReusable to false.

http://neilkilbride.blogspot.com/2008/01/ihttphandler-isreusable-property.html

Upvotes: 1

FlySwat
FlySwat

Reputation: 175633

Short Answer: You don't want to.

Long Answer: A request to an .ASMX is going to non deterministically use a new worker thread, so even if you used the singleton pattern, the life of the singleton will not be known.

Perhaps elaborate on what you want to do, and I can guide you towards the best pattern.

Upvotes: 3

Related Questions