46

I have an application in one of my application pools that has a virtual path of /Site/login.aspx. I want to remove it but it no longer exists on my computer and it's causing me issues setting up AppFabric.

I understand that you can remove these phantom applications by recreating the application in IIS and then hitting Remove. That will get rid of the application from the pool but in this case I can't recreate the application due to the /login.aspx in the virtual path

Any ideas how I remove this erroneous entry?

Pro Backup
  • 914
  • 4
  • 15
  • 33
Col
  • 585
  • 1
  • 4
  • 6

7 Answers7

52

Since I had the same issue; application pools with applications that did not exist anymore, I did some research and finally managed to solve the issue.

Here are some steps:

  1. Locate and edit your IIS 7 configuration file "applicationHost.config" with a text editor. It should be stored in "C:\windows\system32\inetsrv\config" Since the folder is somehow "protected", I usually edit like the following:
    1. Open Windows Explorer
    2. Navigate to "C:\windows\system32\inetsrv\config"
    3. Copy the file "applicationHost.config"
    4. Paste it to a folder where you can edit it, e.g. your Desktop
    5. Open it with your editor of choise and edit it
    6. Copy it back with Windows Explorer to "C:\windows\system32\inetsrv\config"
  2. Make a backup of your "applicationHost.config" file!
  3. Search with a text editor in your "applicationHost.config" for your non-existing applications. They should be located somewhere inside an <application ...> XML node.
  4. Delete the <application ...> node(s) of all your phantom applications.
  5. Save the file and copy it back to "C:\windows\system32\inetsrv\config"
  6. Refresh the IIS management console. Your application pools should now be without the phantom applications you previously deleted.
  7. Actually remove the now empty application pool.

That worked for me, if it does not work for you, please post a comment here. A good help was this posting on the IIS forum.

Please be also aware that when editing the "applicationHost.config" file directly in its original location, you need to use a 64-bit editor (e.g. Notepad++ 64-bit), because otherwise it would get stored in "C:\Windows\SysWOW64\inetsrv\Config" instead of the correct location.

Uwe Keim
  • 2,370
  • 4
  • 29
  • 46
  • 6
    In addition, I came across this article. I didn't use it as the solution above worked for me [Hunting Zombies - How to remove orphaned iis web applications](http://social.technet.microsoft.com/wiki/contents/articles/hunting-zombies-how-to-remove-orphaned-iis-web-applications.aspx) – Col Jul 26 '11 at 09:17
  • 1
    Powershell approach in the link in @Col's comment above is a clean solution and it works great. – Recep Nov 27 '13 at 16:33
6

This is probably safer and simpler than editing applicationHost.config.

Powershell  
PS C:\Windows\system32> import-module WebAdministration
PS C:\Windows\system32> iis:
PS IIS:\> cd .\AppPools
PS IIS:\AppPools> ls
PS IIS:\AppPools> del [name of phantom AppPool]  
Greg Askew
  • 34,339
  • 3
  • 52
  • 81
  • 1
    This removes _application pools_. For removing (phantom) applications, use the approach from the article linked in https://serverfault.com/questions/283467/removing-phantom-applications-from-application-pools-in-iis7#comment278297_290617 – bvgheluwe Nov 07 '17 at 13:32
4

There is an easy way to fix this.

  1. Select the site with the Phantom applications in the application pool.
  2. On the right side "Action" menu select "View Applications". This list should show all the applications that is in the site, Phantom or not.
  3. All you need to do is select the Application and select "Remove" in the right "Action" menu.
Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
Oddvar
  • 41
  • 1
2

Child applications aren't automatically deleted and the IIS Manager can't display them in the tree, so that's your problem...

A quick and robust way is to use a PowerShell script to get all applications, test whether the physical path still exists and if not, delete the application:

# This is for IIS 7, make sure the snap-in is installed first: https://www.iis.net/downloads/microsoft/powershell
Add-PSSnapin WebAdministration

# Get all IIS sites
Get-ChildItem IIS:\Sites | foreach {
    $site = $_;

    # Get all applications without existing physical path
    $applications = Get-ChildItem $site.PsPath | Where-Object { $_.NodeType -eq "application" -and (Test-Path $_.PhysicalPath) -eq $False };

    # List all phantom applications
    $applications | FT

    # Remove applications
    $applications | Remove-WebApplication -Site $site.Name
}
Ronald
  • 256
  • 2
  • 3
  • Just a little correction: IIS Manager can display the phantom applications by selecting the 'Application pools' or 'Sites' node and selecting 'View Applications' on a appPool/site. It only allows deleting from the 'Sites' node though! – Ronald Jan 04 '18 at 10:50
  • This worked perfectly for me, although I had to change "Add-PSSnapIn" to "Import-Module" on Server 2012 R2. – ldam Jul 17 '18 at 13:43
1

Much more simple:

  1. View stale application X and remember the (old) path Y
  2. Create the (old) path / folder Y with Explorer
  3. Refresh IIS Management Console
  4. You will find the just created folder Y and assigned application X
  5. Right click on (old) application X and choose "Remove"
  6. Remove path Y with Explorer
  7. Refresh IIS Management Console again
  8. Hurray
Uwe Keim
  • 2,370
  • 4
  • 29
  • 46
0

Why not edit MetaBase.xml directly? Of course, back it up before that.

Or create a "temp" pool, move all other apps there, remove the orig pool, and rename (if needed) the new pool.

Sunny
  • 5,722
  • 3
  • 21
  • 24
  • 4
    First reason: Because it's IIS7, so editing ApplicationHost.config is required! But I agree, I'm not understanding why it's not just "plonk that URL in a different App Pool first"? – TristanK Jun 23 '11 at 21:55
  • 2
    Thanks for the help. I had moved the URL into a temp pool first and that does remove the problem with AppFabric. However, I still cannot see how I can remove the dodgy application as you cannot delete an app pool as long as it has applications using it, and I can't delete the application from the application pool – Col Jun 24 '11 at 08:14
0

I did a combination of two answers listed above since I did not want to tinker applicationHost.config manually.

Step 1 - Create a temporary app pool - let's say "temp".

Step 2 - Move all the phantom applications to this temp app pool.

Step 3 - Use Powershell from one of the answers above -

Powershell  
PS C:\Windows\system32> import-module WebAdministration
PS C:\Windows\system32> iis:
PS IIS:\> cd .\AppPools
PS IIS:\AppPools> ls
PS IIS:\AppPools> del [name of phantom AppPool]  

Voila!

nixish
  • 1