• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Is there the equivalentof a Load() when a web service starts?

Where do I create certain objects that need to be initialized when a web service starts? They will be used globally by many of the web methods.

thanks,
newbieweb
0
newbieweb
Asked:
newbieweb
  • 2
  • 2
  • 2
2 Solutions
 
Gautham JanardhanCommented:
webservice is just aonther class and u could use the constructor to initialize ur stuff.
0
 
anyoneisCommented:
You can put such code in Global.asax.

David

0
 
anyoneisCommented:
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
newbiewebAuthor Commented:
>> webservice is just aonther class and u could use the constructor to initialize ur stuff.

I see how to put a constructor in, but will that constructor get called when every visitor starts a session?  Isn't there a way for a constructor to be called once?
0
 
Gautham JanardhanCommented:
if u are in doubt abt the construcutor but according to me construcotr get called when every visitor starts a session then do something like this

public void InitializingStuf()
{
}
[webmethod()]
public object FunctionToBeCalled()
{
        InitializingStuf();
        // do other things
}
0
 
newbiewebAuthor Commented:
I want to call a function once, and not initialize it every time thereafter.


[webmethod()]
public object FunctionToBeCalled()
{
        if ( !AlreadyStarted() )
             InitializingStuf();
        // do other things
}

is it possible to know if it's the first session?  And only do certain initialization the first time?

Or does that go against the static nature of a good web service interface?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now