473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Application_Start Question

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
Dec 28 '05 #1
12 1520
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.

"Thomas H. Lanier" <tl*****@ces-web.com> wrote in message
news:uB**************@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

Dec 28 '05 #2
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
Dec 28 '05 #3
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/so...tification.asp

Remy Blaettler
http://www.collaboral.com

Dec 28 '05 #4
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.

"Thomas H. Lanier" <tl*****@ces-web.com> wrote in message
news:eU**************@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

Dec 28 '05 #5
> 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
Dec 28 '05 #6
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
Dec 28 '05 #7
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

Dec 28 '05 #8
> 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 --

Dec 28 '05 #9
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.

"Thomas H. Lanier" <tl*****@ces-web.com> wrote in message
news:%2******************@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

Dec 28 '05 #10
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
Dec 28 '05 #11
Yes, that would work; however, I was hoping not to have to involve another
computer to make it work.

Thanks,

Tommy
Dec 28 '05 #12
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...lingpubliceven
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" <tl*****@ces-web.com>
| References: <uB**************@TK2MSFTNGP11.phx.gbl>
<eZ**************@tk2msftngp13.phx.gbl>
<eU**************@TK2MSFTNGP11.phx.gbl>
<#y**************@TK2MSFTNGP14.phx.gbl>
<#T**************@TK2MSFTNGP09.phx.gbl>
<eS**************@TK2MSFTNGP15.phx.gbl>
| 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: <#d**************@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!TK2MSFT NGP11.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
|
|
|

Dec 29 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AW | last post by:
Hi all, In my Application_Start, I'm initializing the application. ASP.Net calls my Application_Start on the first request, not on the following ones. However, if something goes wrong in my...
6
by: Ober | last post by:
I'm having trouble with my security model, Application_Start, and accessing my database. My ASP.NET app is only going to be running in an intranet environment (not on the public Internet). ...
3
by: msnews.microsoft.com | last post by:
Hi What can you do with the errors occuring in global.asax in Application_Start (or Init) ? What is the best practice here ? What's the elegant solution in this case ? For now (I'm learning)...
4
by: csn | last post by:
Is it possible to have a Response.Redirect in Global.asax in the Application_Start and Session_Start events? We have code in both events, with try-catch blocks, and if an exception is caught, we...
7
by: Gordon Smith | last post by:
I have four (4) ASP.NET Web applications/Web sites on a IIS/6 - Windows Server 2003 production server. 3 of them work fine. I just installed the 4th one and it's Application_Start event is not...
0
by: SeanGallavan | last post by:
Our Environment: Two network load balanced (using Microsoft NLB software) webservers with session maintained in a SQL Server database. NLB is configured with no affinity settings and two...
6
by: Leslie | last post by:
I am attempting to handle errors by using Application_Error. This seems to work fine in most situations. However, if the exception occurs during the Application_Start method, the stand error...
4
by: Marc Missire | last post by:
Hi, I have an issue below I'd love help with, involving a static variable, Application_Start, and a background thread. In global.asax.cs I have a static variable (outside any method) with a...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
0
by: alc | last post by:
Just to clarify something that seems to come up a lot. The Request object is available in Application_Start it just needs to be referenced directly via: System.Web.HttpContext.Current.Request ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.