Running IIS Express from the Command Line
Nội Dung Chính
Running IIS Express from the Command Line
In this article
by Vaidy Gopalakrishnan
Overview
IIS Express is a simple and self-contained version of IIS that is optimized for developers. This walkthrough describes how to run a site using the IIS Express command line.
Prerequisites
You must have the following installed to complete the procedures in this walkthrough:
- Windows XP or newer
- IIS Express
For information about how to download and install IIS Express, see IIS Express Overview.
Running a Site using IIS Express from the Command Line
-
Open a command prompt.
You do not need Administrator user rights to run the commands in this walkthrough. However, you must have Administrator user rights if you want to run IIS Express on ports numbered 1024 or less.
-
Run the following command to navigate to the IIS Express installation folder:
cd \Program Files\IIS Express
or if you are using a 64-bit OS, run the following command:
cd \Program Files (x86)\IIS Express
-
Run the following command to view the IIS Express usage string:
iisexpress /? IIS Express Usage: ------------------ iisexpress [/config:config-file] [/site:site-name] [/siteid:site-id] [/systray:boolean] iisexpress /path:app-path [/port:port-number] [/clr:clr-version] [/systray:boolean] /config:config-file The full path to the applicationhost.config file. The default value is the IISExpress8\config\applicationhost.config file that is located in the user's Documents folder. /site:site-name The name of the site to launch, as described in the applicationhost.config file. /siteid:site-id The ID of the site to launch, as described in the applicationhost.config file. /path:app-path The full physical path of the application to run. You cannot combine this option with the /config and related options. /port:port-number The port to which the application will bind. The default value is 8080. You must also specify the /path option. /clr:clr-version The .NET Framework version (e.g. v2.0) to use to run the application. The default value is v4.0. You must also specify the /path option. /systray:boolean Enables or disables the system tray application. The default value is true. /trace:debug-trace-level Valid values are info or i,warning or w,error or e. Examples: iisexpress /site:WebSite1 This command runs WebSite1 site from the user profile configuration file. iisexpress /config:c:\myconfig\applicationhost.config This command runs the first site in the specified configuration file. iisexpress /path:c:\myapp\ /port:80 This command runs the site from c:\myapp folder over port 80.
-
Run your site using one of the following:
-
Use /config to run a site from a configuration file.
For more information, see Running your site from a configuration file.
-
Use /path to run a site from the application folder.
For more information, see Running your site from the application folder.
Note
The /path option and the /config option cannot be combined.
-
-
Once your site is running, you can use the IIS Express system tray to manage it. For more information, see Use the Windows System Tray to Manage Websites and Applications. Alternatively, you can disable the system tray by running the following option:
/systray:false
Running your site from a configuration file
IIS Express and IIS use the ApplicationHost.config file, which specifies global settings for sites, application pools, handlers, etc. IIS Express uses a default, user-specific ApplicationHost.config file to allow many users to share the same computer without interfering with other user’s settings. This file is located in the %userprofile%\Documents\IISExpress\config folder or %userprofile%\My Documents\IISExpress\config folder, depending on your OS. When you run a site from a configuration file, you can specify which site to run.
You can use the following commands:
-
To run the website Website1 in the default configuration file, run:
iisexpress /site:WebSite1
-
To run the first website in the default configuration file, run:
iisexpress
-
To run the first website in a custom configuration file, run:
iisexpress /config:c:\myconfig\applicationhost.config
-
To run a site called MyBlog from a custom configuration file, run:
iisexpress /config:c:\myconfig\applicationhost.config /site:MyBlog
Note: The /config option specifies the full path of the configuration file. You can omit this option if you want to use the default configuration file. The /site option specifies a particular site in the configuration file. You can omit this option to run the first site in the configuration file.
Running your site from the application folder
You can also use the /path option to run a site directly from a folder. This option works for any type of application, including static HTML, ASP.NET, PHP, and WCF. By default, IIS Express will run the site on http://localhost:8080/
. For a managed website, such as ASP.NET, IIS Express will use .NET 4.0. You can use the /port and /clr options to override these default values.
For example, the following command runs the specified application, “myapp,” on http://localhost:9090/
by using .NET 2.0:
iisexpress /path:c:\myapp\ /port:9090 /clr:v2.0