Solved

Detect when IIS7 web app not in use

Posted on 2013-02-03
7
326 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 82

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 76

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now