christrinder
07-12-2007, 12:04 AM
Hi all. I've been round the houses trying to set-up some sort of automatic, scheduling process that could fire off some of my ASP.NET code to run a series of a routines... but I just can't find a way that works.
I have a number of sites that run on my (windows) box so I've finally decided to call a single web service (therefore accessible from every domain) on each and every session_end (within the global file). The code I've written to call this web service is as follows:
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(myURL);
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.Method = "POST";
objRequest.Timeout = 2000;
objRequest.Credentials = CredentialCache.DefaultCredentials;
StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write("");
myWriter.Close();
objRequest.GetResponse();
This all seems to work, but it can't be the best way. There's no guarantee that a session_end event will be raised within some time periods, and then there will be other times when many are raised etc. Also, I can't work out how to make the above ascyronise (can't spell it!) so speed it up.
SOOOOOOOOO.... does anybody know of a better solution because this feels very piece-meal.
Thanks,
Chris :confused:
I have a number of sites that run on my (windows) box so I've finally decided to call a single web service (therefore accessible from every domain) on each and every session_end (within the global file). The code I've written to call this web service is as follows:
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(myURL);
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.Method = "POST";
objRequest.Timeout = 2000;
objRequest.Credentials = CredentialCache.DefaultCredentials;
StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write("");
myWriter.Close();
objRequest.GetResponse();
This all seems to work, but it can't be the best way. There's no guarantee that a session_end event will be raised within some time periods, and then there will be other times when many are raised etc. Also, I can't work out how to make the above ascyronise (can't spell it!) so speed it up.
SOOOOOOOOO.... does anybody know of a better solution because this feels very piece-meal.
Thanks,
Chris :confused: