First time here? Check out the site's "greatest hits" or read a post from the archives. Feel free to leave a comment or ask a question, and consider subscribing to the latest posts via RSS or e-mail. Thanks for visiting!
« NYTimes Reader - WPF's First Killer App | Main | Patterns & Practices Summit - West 2006 »

We needed to create an IIS Application and Virtual Directory programmatically and while we were doing this, ensure that the VDIR would run only under ASP.NET 2.0. We could certainly shell out to ASPNET_REGIIS.exe to do the work, but this would recycle the whole of IIS (basically every AppPool).

Scott Forsyth at ORCSWeb, my very awesome hosting provider, has an article on a simpler way to make this happen. (It's an older article and older code, but it does work on 2.0 with some simple mods)

It's pretty clever actually...he just spins through the scriptmaps and replaces the current ASP.NET version with the one he wants. The end result is that only that AppPool needs to reset, it's faster, and you don't need to shell out. Thanks ScottF!



Monday, September 25, 2006 11:31:04 PM (Pacific Standard Time, UTC-08:00)
Some Powershell script code (taken directly from our own ConfigTool/ConfigWebSetup.ps1):

$root = New-Object System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC")
$site = $root.get_Children() |Where-Object { $_.ServerComment -eq $AppSiteName }

$webs = $site.get_Children().Find("ROOT", "IIsWebVirtualDir").get_Children()
$web = $webs |Where-Object { $_.get_Name() -eq $AppName }

# $LocalPath = $web.get_Path().Replace("IIS://localhost/", "")
# &C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -sn $LocalPath
$newScriptMaps = $web.ScriptMaps |ForEach-Object { $_ -replace "Framework\\v\d{1}\.\d{1}\.\d{1,5}\\", "Framework\v2.0.50727\" }
$web.ScriptMaps = $newScriptMaps
$web.CommitChanges()
Peter W
Comments are closed.

Contact

Sponsors

Hosting By

On this page...

Tags

Calendar

<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Archives

Google Ads