473,404 Members | 2,114 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,404 software developers and data experts.

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_Disposed is
called, but this is not called in this case.

Thanks, Harri

Jan 19 '06 #1
4 1884
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_Disposed 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_Disposed event manually, while
Application_BeginRequest is called automatically? I added the following
code:

public Global() {
InitializeComponent();
this.Disposed += new EventHandler(Application_Disposed);
}

After this Application_Disposed is called properly. What is the
mechanism in C# so that Application_BeginRequest 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
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,...
12
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...
4
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...
2
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...
1
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...
7
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...
1
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...
4
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...
18
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.