Quantcast
Channel: Configuration & Scripting
Viewing all articles
Browse latest Browse all 780

Programmatically adding vdir and app using appcmd in IIS?

$
0
0

I am trying to use IIS's appcmd to programatically do the equivalent of the following in the IIS Manager application (inetmgr.exe):

  1. In the Connections sidebar on the left, expand to HOSTNAME -> Sites
  2. Right-click Default Web Site and click Add application... from the context menu.
  3. The Add Application dialog will display
    1. In the Alias: textbox type path1/path2
    2. In the Physical Path: textbox type C:\path1\path2
    3. Click OK
  4. This will cause the app to be displayed in the Connections left sidebar under the path HOSTNAME -> Sites -> Default Web Site -> path1 -> path 2
  5. Restarting IIS will cause http://[::1]/path1/path2 to display the application, assuming it's bound to just [::1].

Here is what I have so far to do this programmatically:

# Copy my web.config file for my new site.
copy C:\test\web.config C:\path1\path2\web.config

C:\windows\system32\inetsrv\appcmd add app /site.name:"Default Web Site" /path:path1\path2

C:\windows\system32\inetsrv\appcmd vdir /app.name:"Default Web Site/path1/path2" /path:/ /physicalPath:C:\path1\path2

But after restarting IIS, it never displays in the Connections left sidebar and I can't get to my application either.

However, I can list it using appcmd:

C:\Windows\System32\inetsrv\appcmd list app
...
APP "Default Web Site/windows/gp" (applicationPool:DefaultAppPool)
...

C:\Windows\System32\inetsrv\appcmd list vdir
...
VDIR "Default Web Site/windows/gp/" (physicalPath:C:\path1\path2)
...

What else do I have to do? There's /commit command in appcmd but I don't understand what it does apart from editing an xml .config on the fly at some level...where are my changes?


Viewing all articles
Browse latest Browse all 780

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>