Add new site to iis express using appcmd
To add a new site to IIS Express using the appcmd
command, you can follow these steps:
- Open the Command Prompt as an administrator.
- Navigate to the directory where your IIS Express configuration files are located. By default, this is
C:\Users\<YourUsername>\Documents\IISExpress\config
. - Run the following command to add a new site:
appcmd add site /site.name:"<SiteName>" /physical.path:"<PathToSite>"
Replace
<SiteName>
with the name you want to give your new site, and<PathToSite>
with the physical path to the directory that contains your site's files.
For example:
appcmd add site /site.name:"MyNewSite" /physical.path:"C:\inetpub\wwwroot\MyNewSite"
This will create a new site in IIS Express with the name "MyNewSite" and point to the C:\inetpub\wwwroot\MyNewSite
directory.
- To configure additional settings for your new site, such as the port number or bindings, you can use the following options:
/site.port:<PortNumber>
: specifies the port number to use for the site./site.bindings:"<Binding>"
: specifies a binding for the site, such ashttp://localhost:8080
./site.appPool:"<AppPoolName>"
: specifies the application pool to use for the site.
For example:
appcmd add site /site.name:"MyNewSite" /physical.path:"C:\inetpub\wwwroot\MyNewSite" /site.port:8080 /site.bindings:"http://localhost:8080"
This will create a new site in IIS Express with the name "MyNewSite", point to the C:\inetpub\wwwroot\MyNewSite
directory, use port 8080, and bind to http://localhost:8080
.
- To verify that the site has been added, you can run the following command:
appcmd list site
This will display a list of all sites in IIS Express, including the new site you just added.
Note: The appcmd
command is only available in Windows 7 and later versions. In Windows XP and Vista, you can use the IIS Manager console to add new sites.