Create a method, for instance InitData, which delivers as array or structure
all necessary data to run the all web service methods.
Instruct the users to write this code in Web Applications
sttruct MyData
{
string data1…;
…
string dataN…;
int nun1;
….
};
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
if (Application ["First"] == null)
{
MyData = InitData ();
InitAppData ()
}
Application ["First "] = 1;
}
}
private struct InitAppData ()
{
Application [“Data1”] = MyData.data1;
……..
Application [“DataN”] = MyData.dataN;
…..
}
The Application objects are available for all sessions with the same values.
Another way is to use the Application_Start event in Global.asax to load the
Application objects.
private void Application_Start (object ob, EventArgs e)
{
MyData = InitData();
InitAppData ();
}
Have a fun!
Valentin
Do not hesitate to contact me!
www.wwv-it.eu va*************@t-online.de
"ma*************@gmail.com" wrote:
I am new to web services, and wonder if it is possible to have a web
service run all time and start the constructor before anyone calls any
web method. My problem is that a lot of data is read in the
constructor, and if this is to be loaded every time somebody calls a
web method, thing are really slow. I have tried to just call the web
methods, but it seems like the constructor is called every time.