The detailed configuration of IIS Express (no computer administrator privileges on how to enable debugging VS) Detailed IIS Express, use and precautions

 

Reprinted page: https: //www.cnblogs.com/xbblogs/p/4756552.html

 

Detailed detailed configuration of IIS Express, use and care

 

The Visual Studio 2010 SP1 introduces IIS Express support, which is to be happy about ...... because the built-in ASP.net Development Server can only run a single site can not set the virtual directory, how many items will be how many, etc., etc. and other Bala Bala, I hated it, in short, a very long time I actually developed by IIS. But with IIS has inconvenient place, is the need to open the IIS Admin service, and VS must run in administrator mode to properly open a project and debugging. Always start in administrator mode has more trouble, more depressed, started as an administrator in privileged mode vs state, drag and drop files between programs on the failure ...... In other words, if I want from resources Manager directly drag a file to open vs, on the impossible.

So for IIS Express has been relatively expected.

This article contains content:

1. About the IIS Express

2.IIS Express profile site configuration

3. How to configure IIS Express in 2010 in Visual Studio

4. How to avoid the need for an administrator to start IIS Express

5.IIS Express useful command-line parameters

1. About the IIS Express

Scottgu described in this article along with the ASP.NET MVC 3 new things come, which contains IIS Express 7.5, as follows:

Lightweight, easy to install, the installation package is less than 5M;

Start from Visual Studio, debug application does not need an administrator;

WEB server functionality with full support - support SSL, URL and other write-back module IIS7.x

And IIS7.x exactly the same web.config configuration model

Can and IIS, ASP.net Development Server install, there is no conflict

Support XP and later operating systems, on all systems provide a consistent development function IIS7.x

About IIS Express more conventional installation, use, introduction of relevant articles, I will not say more. Here to talk about how not to see people mentioning place.

2. About Profiles

IIS Express using the configuration file located in the default "My Documents" in the following path: "My Documents \ IIS Express \ Config". Wherein, the ApplicationHost.config is the core of the profile, which is used to define the configuration of the site that hosts, applications and application pools and the entire WEB server. Because it is in my document, so modify it without administrative privileges, which means you can directly modify. After modification, next time you start the application will take effect.

In applicationhost.config content, <system.applicationHost> is used to define the site and application pool. By default, it reads as follows:

Copy the code
 1 <system.applicationHost>   
 2     
 3 <applicationPools>   
 4 <add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 5 <add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 6 <add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 7 <add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 8 <add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />   
 9 <applicationPoolDefaults managedRuntimeLoader="v4.0">   
10 <processModel />   
11 </applicationPoolDefaults>   
12 </applicationPools>   
13     
14 <!--   
15     
16 The <listenerAdapters> section defines the protocols with which the   
17 Windows Process Activation Service (WAS) binds.   
18     
19 -->   
20 <listenerAdapters>   
21 <add name="http" />   
22 </listenerAdapters>   
23     
24 <sites>   
25 <site name="WebSite1" id="1" serverAutoStart="true">   
26 <application path="/">   
27 <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />   
28 </application>   
29 <bindings>   
30 <binding protocol="http" bindingInformation=":8080:localhost" />   
31 </bindings>   
32 </site>   
33 <applicationDefaults applicationPool="Clr4IntegratedAppPool" />   
34 <virtualDirectoryDefaults allowSubDirConfig="true" />   
35 </sites>   
36     
37 <webLimits />   
38     
39 </system.applicationHost>  
Copy the code

IIS Express five applications built pools, respectively .Net integration / classic mode 2.0 / 4.0, and a pool unmanaged. The default application pool versions <spplicationPoolDefaults> section to configure. <Sites> section is used to configure the site. The default application pool and a virtual directory site configuration configured by default <applicationDefaults> and <virtualDirectoryDefaults> node. Under the above node by default we do not need much attention, because only the <site> node under the <sites> we need to focus most cases, save where the definition of websites, applications, and what we need to really care about of.

①. Each <site> is a website.

This Web site in IIS is the same concept. serverAutoStart sets whether With IIS Express start automatically start. If set to true, then every time IIS Express will start automatically load (if not specified, then the site), otherwise will only load and run to specify a particular site mode.

Use IIS Express to load a particular Web site syntax is: IISExpress.exe / site: <site name>

②. <Bindings> <site> binding information provided under this site.

<Binding> is a port binding information in each node. Typical binding configuration as follows: <binding protocol = "http" bindingInformation = "*: 8080: localhost" />

protocol specifies the protocol type binding (IIS Express built-in HTTP and HTTPS protocol support), and specific binding information "*:: 8080 localhost" is specified, it has three parts: "bound IP: port: host name. " By default, bound to any local IP, non-reserved port, bound to localhost. Note that this localhost, pay attention to, under certain circumstances may cause you to very confused, please refer to later in this article.

③. <Application> This section sets the application site

Each site will require at least one mapped path to "/" application (which is mapped to the root directory). In addition, you can continue to add parallel <application> different paths, which is similar to an application in IIS Web site in the configuration.

For example, in FishSite this site, I need to add a separate application that is mapped to the root directory under the fish, then I can be configured:

Copy the code
 1 <site name="FishSite" id="2">   
 2 <application path="/" applicationPool="Clr2IntegratedAppPool">   
 3 <virtualDirectory path = "/" physicalPath = "<root of the site>" />   
 4 </application>   
 5 <application path="/fish" applicationPool="Clr2IntegratedAppPool">   
 6 <virtualDirectory path = "/" physicalPath = "<the root directory of this application>" />   
 7 <virtualDirectory path = "/ content /" physicalPath = "</ fish / content / directory corresponding to the virtual directory>" />   
 8 </application>   
 9 <bindings>   
10 <binding protocol="http" bindingInformation="*:5000:localhost" />   
11 </bindings>   
12 </site>  
Copy the code

In <site>, only the path = "/" This application is required (not missing), the other can all be optionally added.

④. <VirtualDirectory> set mapping information directory

See the code shown above. In each of the <application> section, there must be at least one path = "/" the virtualDirectory, which represents the location of this directory mapping. In addition, you can add more different paths mapped virtual directory manually.

3. Support on virtual directory

IIS Express supports virtual directory, which is for me a very important improvement, because the actual projects often have a lot of shared directory, such as upload directory, configuration files, directories, etc., in ASP.net Development Server in these It is impossible.

IIS Express and IIS site model is consistent, the most basic is the site, the site can be distinguished under the application, virtual directory.

How to manually create the configuration file them, please refer to the Introduction section to create your own. How to create in VS it?

①, will use IIS or ASP.net Development Server project to migrate to IIS Express

Note: You need to install Visual Studio 2010 SP1 to make Visual Studio 2010 supports IIS Express.

In the "Solution Explorer" right-click the Web site project, and select "Use IIS Express ...." You can:

image

Visual Studio will use a new default port to create a site in IIS Express in.

②, if you want to map to the current project under an existing site or a new site's root directory as a virtual directory, it is recommended to change the (project properties -WEB) in the project properties:

image

When you're finished, click on "Create Virtual Directory" to complete the conversion. VS will automatically configure IIS Express in this machine.

③, if you want to be mapped to a local directory (such as resource sharing, upload directory, etc.) to the application host sites under IIS Express

You can refer to the above description of the configuration file manually change. Looks like IIS Express in appcmd can also change, but personally feel that such a simple configuration, directly edit to get, with appcmd then need to go to learn how to use it, blame the trouble.

The foregoing examples refer to related content.

4. About an administrator to start

IIS Express is designed to avoid the need for administrator rights will be able to complete most of the operation. But it will be individual cases requires administrator privileges to run (I was in here stumbled to study the long-N). Such restrictions include:

Bound to a reserved port (usually located below 1024 port, such as 80,88,443, etc.);

Not bound localhost, but to bind the domain name or other content;

Using HTTPS, but not within the scope ports 44300-44399;

HTTPS uses its own SSL certificate.

①, using the port reserved

Usually operating systems HTTP.sys (core network) port design is reserved ports below 1024, if IIS Express needs to bind to these ports, it will need to have administrator privileges, otherwise it will fail. Error like this:

image

Reflected in the system log, it is one such error:

image

To solve this problem is very simple, as long as the port can be bound to a non-reserved port (greater than 1024), or by using an administrator to start it Note 1.

②, bundled with other domain name

By default, IIS Express can only bind to the localhost. If you need to bind to a specific domain name for external access but there is no solution, we will encounter the problem of failure.

To resolve them, it is simple - to start it as administrator Note 1.

③, using HTTPS, but not within the port of 44300-44399

When IIS Express for carrying HTTPS site testing, the port will be limited to the 44300-44399, which is also operating system limitation. If you exceed this range, you need to start it to work properly Note 1 as an administrator.

④, using its own SSL certificate HTTPS

IIS Express installs a default self-signed certificate for the development of a test, which allows developers to develop in the absence of SSL certificate cases. However, if the site uses its own SSL certificate, it will lead IIS Express administrator needs to start Notes 1.

5. With regard to the command-line startup options

①, use your own config file

IIS Express will use saved in "My Documents" applicationhost.config default. But if we start it in command-line mode, you can specify the path to the configuration file.

Command line is: iisexpress / config: <profile path>

For the development team, which will be useful, such as creating global config checked into source control, this can synchronize the global server configuration directory structure (of course, if little or no directory mapping project, then no much sense). Start IIS Express uses this command line to start, eliminating the need for each project will have to configure IIS Express pull out of trouble (at the same time, the development server configuration can be saved directly to the project, thus avoiding the development of each person may have a server difference).

In this case, the debugger can use VS's "Attach to Process" to complete.

②, start a temporary site

In some cases, we need to start a temporary site (for example, to quickly create a temporary server, etc.), you can create a similar line to the command:

iisexpress / path: <web directory> / port: <port> / clr: <CLR version, V2.0 | V4.0>

iis express will copy the configuration file to a temporary directory, and change them and then start site information, it will not affect the machine has been configured to the site of

The Visual Studio 2010 SP1 introduces IIS Express support, which is to be happy about ...... because the built-in ASP.net Development Server can only run a single site can not set the virtual directory, how many items will be how many, etc., etc. and other Bala Bala, I hated it, in short, a very long time I actually developed by IIS. But with IIS has inconvenient place, is the need to open the IIS Admin service, and VS must run in administrator mode to properly open a project and debugging. Always start in administrator mode has more trouble, more depressed, started as an administrator in privileged mode vs state, drag and drop files between programs on the failure ...... In other words, if I want from resources Manager directly drag a file to open vs, on the impossible.

So for IIS Express has been relatively expected.

This article contains content:

1. About the IIS Express

2.IIS Express profile site configuration

3. How to configure IIS Express in 2010 in Visual Studio

4. How to avoid the need for an administrator to start IIS Express

5.IIS Express useful command-line parameters

1. About the IIS Express

Scottgu described in this article along with the ASP.NET MVC 3 new things come, which contains IIS Express 7.5, as follows:

Lightweight, easy to install, the installation package is less than 5M;

Start from Visual Studio, debug application does not need an administrator;

WEB server functionality with full support - support SSL, URL and other write-back module IIS7.x

And IIS7.x exactly the same web.config configuration model

Can and IIS, ASP.net Development Server install, there is no conflict

Support XP and later operating systems, on all systems provide a consistent development function IIS7.x

About IIS Express more conventional installation, use, introduction of relevant articles, I will not say more. Here to talk about how not to see people mentioning place.

2. About Profiles

IIS Express using the configuration file located in the default "My Documents" in the following path: "My Documents \ IIS Express \ Config". Wherein, the ApplicationHost.config is the core of the profile, which is used to define the configuration of the site that hosts, applications and application pools and the entire WEB server. Because it is in my document, so modify it without administrative privileges, which means you can directly modify. After modification, next time you start the application will take effect.

In applicationhost.config content, <system.applicationHost> is used to define the site and application pool. By default, it reads as follows:

Copy the code
 1 <system.applicationHost>   
 2     
 3 <applicationPools>   
 4 <add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 5 <add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 6 <add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 7 <add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />   
 8 <add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />   
 9 <applicationPoolDefaults managedRuntimeLoader="v4.0">   
10 <processModel />   
11 </applicationPoolDefaults>   
12 </applicationPools>   
13     
14 <!--   
15     
16 The <listenerAdapters> section defines the protocols with which the   
17 Windows Process Activation Service (WAS) binds.   
18     
19 -->   
20 <listenerAdapters>   
21 <add name="http" />   
22 </listenerAdapters>   
23     
24 <sites>   
25 <site name="WebSite1" id="1" serverAutoStart="true">   
26 <application path="/">   
27 <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />   
28 </application>   
29 <bindings>   
30 <binding protocol="http" bindingInformation=":8080:localhost" />   
31 </bindings>   
32 </site>   
33 <applicationDefaults applicationPool="Clr4IntegratedAppPool" />   
34 <virtualDirectoryDefaults allowSubDirConfig="true" />   
35 </sites>   
36     
37 <webLimits />   
38     
39 </system.applicationHost>  
Copy the code

IIS Express five applications built pools, respectively .Net integration / classic mode 2.0 / 4.0, and a pool unmanaged. The default application pool versions <spplicationPoolDefaults> section to configure. <Sites> section is used to configure the site. The default application pool and a virtual directory site configuration configured by default <applicationDefaults> and <virtualDirectoryDefaults> node. Under the above node by default we do not need much attention, because only the <site> node under the <sites> we need to focus most cases, save where the definition of websites, applications, and what we need to really care about of.

①. Each <site> is a website.

This Web site in IIS is the same concept. serverAutoStart sets whether With IIS Express start automatically start. If set to true, then every time IIS Express will start automatically load (if not specified, then the site), otherwise will only load and run to specify a particular site mode.

Use IIS Express to load a particular Web site syntax is: IISExpress.exe / site: <site name>

②. <Bindings> <site> binding information provided under this site.

<Binding> is a port binding information in each node. Typical binding configuration as follows: <binding protocol = "http" bindingInformation = "*: 8080: localhost" />

protocol specifies the protocol type binding (IIS Express built-in HTTP and HTTPS protocol support), and specific binding information "*:: 8080 localhost" is specified, it has three parts: "bound IP: port: host name. " By default, bound to any local IP, non-reserved port, bound to localhost. Note that this localhost, pay attention to, under certain circumstances may cause you to very confused, please refer to later in this article.

③. <Application> This section sets the application site

Each site will require at least one mapped path to "/" application (which is mapped to the root directory). In addition, you can continue to add parallel <application> different paths, which is similar to an application in IIS Web site in the configuration.

For example, in FishSite this site, I need to add a separate application that is mapped to the root directory under the fish, then I can be configured:

Copy the code
 1 <site name="FishSite" id="2">   
 2 <application path="/" applicationPool="Clr2IntegratedAppPool">   
 3 <virtualDirectory path = "/" physicalPath = "<root of the site>" />   
 4 </application>   
 5 <application path="/fish" applicationPool="Clr2IntegratedAppPool">   
 6 <virtualDirectory path = "/" physicalPath = "<the root directory of this application>" />   
 7 <virtualDirectory path = "/ content /" physicalPath = "</ fish / content / directory corresponding to the virtual directory>" />   
 8 </application>   
 9 <bindings>   
10 <binding protocol="http" bindingInformation="*:5000:localhost" />   
11 </bindings>   
12 </site>  
Copy the code

In <site>, only the path = "/" This application is required (not missing), the other can all be optionally added.

④. <VirtualDirectory> set mapping information directory

See the code shown above. In each of the <application> section, there must be at least one path = "/" the virtualDirectory, which represents the location of this directory mapping. In addition, you can add more different paths mapped virtual directory manually.

3. Support on virtual directory

IIS Express supports virtual directory, which is for me a very important improvement, because the actual projects often have a lot of shared directory, such as upload directory, configuration files, directories, etc., in ASP.net Development Server in these It is impossible.

IIS Express and IIS site model is consistent, the most basic is the site, the site can be distinguished under the application, virtual directory.

How to manually create the configuration file them, please refer to the Introduction section to create your own. How to create in VS it?

①, will use IIS or ASP.net Development Server project to migrate to IIS Express

Note: You need to install Visual Studio 2010 SP1 to make Visual Studio 2010 supports IIS Express.

In the "Solution Explorer" right-click the Web site project, and select "Use IIS Express ...." You can:

image

Visual Studio will use a new default port to create a site in IIS Express in.

②, if you want to map to the current project under an existing site or a new site's root directory as a virtual directory, it is recommended to change the (project properties -WEB) in the project properties:

image

When you're finished, click on "Create Virtual Directory" to complete the conversion. VS will automatically configure IIS Express in this machine.

③, if you want to be mapped to a local directory (such as resource sharing, upload directory, etc.) to the application host sites under IIS Express

You can refer to the above description of the configuration file manually change. Looks like IIS Express in appcmd can also change, but personally feel that such a simple configuration, directly edit to get, with appcmd then need to go to learn how to use it, blame the trouble.

The foregoing examples refer to related content.

4. About an administrator to start

IIS Express is designed to avoid the need for administrator rights will be able to complete most of the operation. But it will be individual cases requires administrator privileges to run (I was in here stumbled to study the long-N). Such restrictions include:

Bound to a reserved port (usually located below 1024 port, such as 80,88,443, etc.);

Not bound localhost, but to bind the domain name or other content;

Using HTTPS, but not within the scope ports 44300-44399;

HTTPS uses its own SSL certificate.

①, using the port reserved

Usually operating systems HTTP.sys (core network) port design is reserved ports below 1024, if IIS Express needs to bind to these ports, it will need to have administrator privileges, otherwise it will fail. Error like this:

image

Reflected in the system log, it is one such error:

image

To solve this problem is very simple, as long as the port can be bound to a non-reserved port (greater than 1024), or by using an administrator to start it Note 1.

②, bundled with other domain name

By default, IIS Express can only bind to the localhost. If you need to bind to a specific domain name for external access but there is no solution, we will encounter the problem of failure.

To resolve them, it is simple - to start it as administrator Note 1.

③, using HTTPS, but not within the port of 44300-44399

When IIS Express for carrying HTTPS site testing, the port will be limited to the 44300-44399, which is also operating system limitation. If you exceed this range, you need to start it to work properly Note 1 as an administrator.

④, using its own SSL certificate HTTPS

IIS Express installs a default self-signed certificate for the development of a test, which allows developers to develop in the absence of SSL certificate cases. However, if the site uses its own SSL certificate, it will lead IIS Express administrator needs to start Notes 1.

5. With regard to the command-line startup options

①, use your own config file

IIS Express will use saved in "My Documents" applicationhost.config default. But if we start it in command-line mode, you can specify the path to the configuration file.

Command line is: iisexpress / config: <profile path>

For the development team, which will be useful, such as creating global config checked into source control, this can synchronize the global server configuration directory structure (of course, if little or no directory mapping project, then no much sense). Start IIS Express uses this command line to start, eliminating the need for each project will have to configure IIS Express pull out of trouble (at the same time, the development server configuration can be saved directly to the project, thus avoiding the development of each person may have a server difference).

In this case, the debugger can use VS's "Attach to Process" to complete.

②, start a temporary site

In some cases, we need to start a temporary site (for example, to quickly create a temporary server, etc.), you can create a similar line to the command:

iisexpress / path: <web directory> / port: <port> / clr: <CLR version, V2.0 | V4.0>

iis express will copy the configuration file to a temporary directory, and change them and then start site information, it will not affect the machine has been configured to the site of

Guess you like

Origin www.cnblogs.com/LZXX/p/12082567.html