Solved

Detect when IIS7 web app not in use

Posted on 2013-02-03
7
330 Views
Last Modified: 2013-02-18
I need to be able to detect when no users are using a particular web app so that I can do some maintenance on the server.  I do not want to log in to the server and manually do the work.  I have a couple of services running and I am not adverse to writing another one or something scheduled or whatever but I don't want to write anything in the web app itself.  This solution needs to stand alone on the server (Windows 7).   I started looking at this namespace - Microsoft.Web.Administration  but I am not sure if this is the correct starting place.  
Thanks
LT
0
Comment
Question by:codelegs
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38849457
With plain web pages, you can't tell if someone is 'using' them because they just get served as files and it's done until they request the next one.  What is there about the web app that makes it possible to detect when there aren't any 'users'?
0
 
LVL 9

Expert Comment

by:Aeriden
ID: 38849480
The problem is that I don't think you can really tell if users are connected as they move from page to page (or within a page via post-backs) except for the moment they make a call to retrieve data.  IIS also leaves some connection handles available even after visitors have closed their browser for optimization purposes.

Load Balanced IIS servers can sometimes be useful with this process (but a lot more complex and requires Windows Servers).  Or proper .NET development can allow visitors to resume even after the web server has been done for a period of time.
0
 
LVL 77

Expert Comment

by:arnold
ID: 38849627
Not sure what kind of work you need to perform on a live/production site.
You can have a test site with Athens same functionality on which you can work and test and then publish the changes to the production/live one.

As you referenced, the only way to track if someone is likely using the app is by including the mechanism within the app.
I.e. using the user login to create an entry in a database indicating initial time. Every page access updates the most recent access as a verification that the user is still accessing resource using a cookie. In the absence of updates within a set amounts time (5,10 minutes) based on the state cookie expiration, the user entry is deleted as presumptive that the user is no longer accessing the site.
With your criteria in mind, you would need to include the current page the user is on and take into account whether the component you are working on might adversely affect the users' experience.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 17

Accepted Solution

by:
Rovastar earned 250 total points
ID: 38849720
I agree with the others above you need to understand what it means when no-one is using your app.

Also you do not say how much traffic you get, it is possible that it always has active users.  But if that is the case then you really need to look at web farm and load balancing environments for your setup.

From an IIS admin point of view there are direct indications that the site is not being used.

When any traffic goes to the site it runs a worker process. After a period of inactivity the worker process closes by default that is 30 minutes. So if there is no worker process for that site (well, technically app pool that the site/app runs under) then it is safe to do the deployment.

I think looking at WorkerPRocessState might help here but I am no coder.
http://msdn.microsoft.com/en-us/library/microsoft.web.administration.workerprocessstate%28v=vs.90%29.aspx

Also look at how you are managing session. InProc sessions are stored in the worker process.
0
 

Author Comment

by:codelegs
ID: 38853494
Dave, I think you have helped.  But is there a session that ends on the server that would tell me no one has a session?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38854619
0
 

Author Closing Comment

by:codelegs
ID: 38903637
WorkerProcess is the correct place - thanks
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Store results in vb.net 3 24
Help with exporting to excel 4 36
TLS/SSL Diable 3DES ciper suites 4 53
Running powershell scripts from ASP.NET 6 31
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question