Application_Start Question

T

Thomas H. Lanier

In ASP.NET is there a way to run some code when IIS first loads?

The Application_Start event is called when the first resource (such as a
page) in an ASP.NET application is requested.

I need to run some code BEFORE any requests have been received.

Thanks,

Tommy
 
K

Kevin Spencer

The Application_Start method is called before the Request is processed.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
T

Thomas H. Lanier

I need to run code before any request occurs (not just before the first
request is processed).

Sequence of events:

* IIS starts
* I need code to run here
* 10 minutes later (for example) the first request comes in
* Application_start event triggers

Tommy
 
K

Kevin Spencer

What sort of work is this code supposed to be doing?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
R

Remy

Can you just load the webpage manually? I know that is kinda obvious...
;-)
Why do you need to run the code when you start IIS?

Don't think there is an ASP event when IIS starts, but if it is really
important you should be able to build an application that listens to
the Service Start Event from IIS and then maybe calls a webservice or
something to execute your code.

COM+ event service example:
http://www.codeproject.com/csharp/solutionlcenotification.asp

Remy Blaettler
http://www.collaboral.com
 
T

Thomas H. Lanier

What sort of work is this code supposed to be doing?

I need to create a thread that will poll some devices on the web and update
a database. The polling must occur whether or not someone tries to access
the web site. The data will be accessible from ASP.NET web pages.

Tommy
 
T

Thomas H. Lanier

The technique must be available using a standard ASP.NET web hosted account
without making any special requests of the ISP hosting provider.

Thanks,

Tommy
 
R

Remy

A low tech approach would then be to just put this into the
Application_Start event and setup a website monitor. This way you
ensure that your website is called every 5min (or whatever you choose).
So even if the IIS restarts the Application_Start event will be execute
soon again.

Remy Blaettler
 
A

addup

I need to create a thread that will poll some devices on the web and update a database.
The polling must occur whether or not someone tries to access the web site

Sounds like you need a (windows) service feeding a database, with a web
app frontend to query the said database.

The service can (and will) run independent of IIS.

Hope this helps
-- addup --
 
K

Kevin Spencer

Okay, so this data is supposed to be available to ASP.Net pages. So why does
it have to run whether or not someone visits the site? I'm asking because if
you're hosting your site, your options are very few, and it may be time to
figure out a different solution.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
T

Thomas H. Lanier

Real time data must be collected whether someone is viewing the web site or
not.

I was hoping to be able to solve the problem using a standard web hosting
account. This may not be possible.

Thanks,

Tommy
 
T

Thomas H. Lanier

Yes, that would work; however, I was hoping not to have to involve another
computer to make it work.

Thanks,

Tommy
 
S

Steven Cheng[MSFT]

Hi Tommy,

As for the ASP.NET serverside code, it can only process those events or
objects which is living in the asp.net's runtime pipeline.... We can not
intercept IIS level events in ASP.NET code.... As for your requirement:

==================
I was hoping to be able to solve the problem using a standard web hosting
account. This may not be possible.
==================

Does the "BeginRequest" event in the asp.net httpmodule helps? Each
request to asp.net resource will be processed through a list of httpmodules
(which is the first step in asp.net serverside pipeline...), and the
BeginRequest event is the first event we can intercept that request in
httpmodule:

#Handling Public Events
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhandlingpubliceven
ts.asp?frame=true

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




--------------------
| From: "Thomas H. Lanier" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<#[email protected]>
<#TmrqP#[email protected]>
<eSBGsu#[email protected]>
| Subject: Re: Application_Start Question
| Date: Wed, 28 Dec 2005 16:12:39 -0500
| Lines: 11
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Response
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: adsl-223-32-152.aep.bellsouth.net 68.223.32.152
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:367402
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Real time data must be collected whether someone is viewing the web site
or
| not.
|
| I was hoping to be able to solve the problem using a standard web hosting
| account. This may not be possible.
|
| Thanks,
|
| Tommy
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top