all groups > dotnet web services > february 2008 >
You're in the

dotnet web services

group:

Init method?



Init method? sameertanna
2/22/2008 7:55:01 PM
dotnet web services: Hi,

I was wondering if there is any "Init method" that is called when the web
service is first deployed. I would like to initialize certain objects when
the web service is first deployed.

Any help/suggestions will be highly appreciated.
Re: Init method? John Saunders [MVP]
2/23/2008 1:05:15 PM
[quoted text, click to view]

What do you mean, "first deployed"? How would you access these objects after
they were initialized?
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Re: Init method? Spam Catcher
2/24/2008 11:10:16 PM
=?Utf-8?B?c2FtZWVydGFubmE=?= <sameertanna@discussions.microsoft.com>
wrote in news:7FFD210D-8A84-4D61-A948-DE9E071C4CBD@microsoft.com:

[quoted text, click to view]

I think you can use the Global.asax.

But one thing to keep aware of, Web Services like ASP.NET is generally
stateless. So take care when creating initialization logic, it can be
called anytime whenever IIS/ASP.NET feels like recycling the process.

--
Re: Init method? sameertanna
2/27/2008 8:08:00 PM
Hi John,

By first deployed, I just mean when the webservice is deployed. For example,
in Java servlets there is an Init() method which is called when a servlet is
called for the first time after the application is deployed.

From this method I would like to call a static function which initializes
certain static objects, for example, xmlDocument objects.

Sameer

[quoted text, click to view]
Re: Init method? sameertanna
2/27/2008 8:10:00 PM
Hi,

It will be great if you could throw some light on what you mean by
"recycling", or point me to some resource which would have the information
about it.
I would like to initialize certain static objects. Would that be advisable
using Global.asax?

Thanks,
Sameer


[quoted text, click to view]
Re: Init method? John Saunders [MVP]
2/28/2008 2:39:55 PM
[quoted text, click to view]

1) There is no concept in ASP.NET that is equivalent to the J2EE concept of
initialization during deployment. I strongly recommend you reconsider that
aspect of your design, before you spend too much time duplicating that
functionality.
2) Each ASP.NET web application is hosted within an AppDomain. This is sort
of like a Unix process; just a bit lighter-weight. In various circumstances,
the application may be recycled - a new AppDomain will be created, and the
application will be activated within it, so that all new requests will go to
the new AppDomain. When all requests have finished in the old AppDomain, the
old AppDomain will be removed.

If you will give me an idea of what sorts of static objects you need to
initialize, I may be able to help you further.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

AddThis Social Bookmark Button