|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Application_Start QuestionIn 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 The Application_Start method is called before the Request is processed.
-- Show quoteHide quoteHTH, 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. "Thomas H. Lanier" <tlan***@ces-web.com> wrote in message news:uBT4IE8CGHA.1816@TK2MSFTNGP11.phx.gbl... > 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 > > 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 What sort of work is this code supposed to be doing?
-- Show quoteHide quoteHTH, 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. "Thomas H. Lanier" <tlan***@ces-web.com> wrote in message news:eUHX4d9CGHA.4016@TK2MSFTNGP11.phx.gbl... >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 > > > 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 > I need to create a thread that will poll some devices on the web and update a database. Sounds like you need a (windows) service feeding a database, with a web> The polling must occur whether or not someone tries to access the web site app frontend to query the said database. The service can (and will) run independent of IIS. Hope this helps -- addup -- 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. -- Show quoteHide quoteHTH, 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. "Thomas H. Lanier" <tlan***@ces-web.com> wrote in message news:%23TmrqP%23CGHA.1180@TK2MSFTNGP09.phx.gbl... >> 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 > > 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 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" <tlan***@ces-web.com> <eZJds08CGHA.2***@tk2msftngp13.phx.gbl> | References: <uBT4IE8CGHA.1***@TK2MSFTNGP11.phx.gbl> <eUHX4d9CGHA.4***@TK2MSFTNGP11.phx.gbl> <#ywo7$9CGHA.2***@TK2MSFTNGP14.phx.gbl> <#TmrqP#CGHA.1***@TK2MSFTNGP09.phx.gbl> <eSBGsu#CGHA.2***@TK2MSFTNGP15.phx.gbl> | Subject: Re: Application_Start Question microsoft.public.dotnet.framework.aspnet:367402| 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: <#d4KwN$CGHA.2***@TK2MSFTNGP11.phx.gbl> | 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 Show quoteHide quote | 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 | | | 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 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 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
Other interesting topics
Resources and class libraries
ViewState: why? Nested asp.net application Help: Why <mobile:label> doesn't render HTML tag? Allow multiple image swap onmouseover Basic formatting for HTML in ASP.NET 1.1 ? What caused the postback? Access to a HiddenFiled in a Content control from javaScript masking url in datagrid hyperlink column in status bar Overriding default skin |
|||||||||||||||||||||||