473,569 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect if web site has been stopped?

I have an ASP.NET application that runs threads in background. Application
does not close if the web site is stopped. So how can the application get an
event when the site has been stopped, so that it could shutdown itself?

Application already closes itself gracefully if Application_Dis posed is
called, but this is not called in this case.

Thanks, Harri

Jan 19 '06 #1
4 1891
Are you stopping the application from IIS, or are you expecting the
application to stop when you hit the stop button on the browser?

The web client's stop button mearly stops the current http transfer at
the client level (closing the ports). Stopping the web browser will
have no effect on the application, which shuts down only after all
sessions have ended, so the actual time that the session ends will vary
based on a variety of factors outside of your control.

If a client requests a page--any page--it will begin a session for that
user. If the user does not request another page, the session will end
after 20 minutes (by default-you can change the session timeout). If
another page is requested before the session times out, the session
will end 20 minutes after the last page request. Only after all
sessions have timed out will the application close (and even then,
you'll probably have to wait another minute or so until the next
garbage collection for it to really leave memory).

-Mark

Jan 19 '06 #2
OK, but if the whole web site is stopped in IIS, is there any way to find out
that?

What is the .NET object that represents the web site, where the current
ASP.NET application is running?

Jan 20 '06 #3
Harri Pesonen wrote:
OK, but if the whole web site is stopped in IIS, is there any way to find out
that?

What is the .NET object that represents the web site, where the current
ASP.NET application is running?


Having long-running threads within the ASP.NET application is not
recommended. If it's not too late to re-architect, could you not have
your threads in a separate process and use remoting to communicate with
them? That way, I believe, the Application_End event will fire and you
can tell the other process to shut down.

If you must keep the threads within the application, I think you'll be
looking at kludges. Most horrendous one I can think of is to
periodically perform a web request against yourself - if you don't
respond, there's a good chance you've been shut down :-D

Sorry I can't think of something more constructive here, it's not an
exact match for situations I've had in the past. I've had long-running
threads, but not even had to consider the site being stopped whilst
they're working.

Damien

Jan 20 '06 #4
Damien wrote:
Harri Pesonen wrote:
OK, but if the whole web site is stopped in IIS, is there any way to find out
that?

What is the .NET object that represents the web site, where the current
ASP.NET application is running?


Having long-running threads within the ASP.NET application is not
recommended. If it's not too late to re-architect, could you not have
your threads in a separate process and use remoting to communicate with
them? That way, I believe, the Application_End event will fire and you
can tell the other process to shut down.

If you must keep the threads within the application, I think you'll be
looking at kludges. Most horrendous one I can think of is to
periodically perform a web request against yourself - if you don't
respond, there's a good chance you've been shut down :-D

Sorry I can't think of something more constructive here, it's not an
exact match for situations I've had in the past. I've had long-running
threads, but not even had to consider the site being stopped whilst
they're working.


OK, thanks. I already have Application_Dis posed implemented and it works
fine, application closes gracefully, if for example web.config is touched.

Application_End didn't work as well, it was not called. Btw, why I need
to add Application_Dis posed event manually, while
Application_Beg inRequest is called automatically? I added the following
code:

public Global() {
InitializeCompo nent();
this.Disposed += new EventHandler(Ap plication_Dispo sed);
}

After this Application_Dis posed is called properly. What is the
mechanism in C# so that Application_Beg inRequest is called automatically?

It just would make sense to react to web site stopping as well, as this
seems to be the only GUI method for stopping a web application.

-- Harri
Jan 20 '06 #5

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

Similar topics

39
8632
by: David Jubinville | last post by:
Hi All, I've run into a bit of an interesting problem with CSS and font DPI and would certainly welcome help. Problem: Page layout defined in CSS has font size issues (overlapping frames, text overflowing out of popup window, etc) on a windows systems using 120dpi fonts (large fonts), but everything looks perfect in 96dpi small fonts.
12
3353
by: |-|erc | last post by:
when a user clicks back to get to my site, I want it to run a javascript function. can you detect when the FORWARD button is greyed out? Herc -- I call3d this fugly and I'm proud www.supernerd.com.au/~gray77/kath1.jpg
4
2792
by: Chris Johnson | last post by:
Hey all, I have a small app I have developed that periodically pings a list of server and returns their status. Given my environment I have setup the program such that a server can be down 4 minutes before I get an alert. My problem now is that is a server is rebooted, it will be back up before the 4 minute window and I will not be aware...
2
9252
by: Cam | last post by:
Hi to all I have searched this subject and found some posts but none of them seem to answer my problem. I am developing a shop site and need to detect when a session times out through inactivity and tell the user that it has been reset and he has to start over. I set some session variables in a global.asa file so when the user restarts
1
1299
by: DrShevek | last post by:
Hi, Apologies if this has been discussed before but I have tried to search and found nothing really helpful as I am not entirely sure exactly what to search for..! Is it possible to detect via ASP.Net if a web site on a remote (internal) IIS server is available? Background: We have 4 sites in star layout WAN with site A in the
7
3810
by: hiriumi | last post by:
Hello folks, I have a web application that has basic authentication turned on (IIS). What I would like to accomplish is detect whether user is navigating away from the site or simply going to the different page using JavaScript. I am aware that it is easy to detect where you came from (referrer), but I haven't been able to find a way to where...
1
4838
by: Jessica | last post by:
Hi, I'm sorry if this has been asked before. I'm a designer and occasional javascript hacker, not a javascript writer. I cannot believe I have spent over 4 hours searching for this on Google and nothing I have found solves this silly little problem. Background ---------- I have been assigned a poorly-designed site to SEO. It has a...
4
2186
by: Per Bolmstedt | last post by:
(This question has been asked previously in this group, but I don't think it was ever really properly answered.) I want to use reflection - preferably - to find all Web Forms in my web site that inherit my base page class (which in turn inherits System.Web.UI.Page). Behold the following code: For Each asm As System.Reflection.Assembly In...
18
9039
by: sebastian | last post by:
Can this be done without client-side scripting? I thought sessions might be the answer but after some testing found that sometimes the old session data remained even after the user left the site and returned. Just had an idea, though. Perhaps I could access the users Referrer header?
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.