8 out of 15 rated this helpful - Rate this topic

Web Servers in Visual Studio for ASP.NET Web Projects

When you develop Web projects in Visual Studio, you need a Web server to test or run them. Visual Studio lets you test with different Web servers, including IIS Express, Internet Information Services (IIS), or the built-in Visual Studio Development Server. You can use any of these servers with a file-based Web application project. For a file-based Web site project, you can use IIS Express or the built-in Visual Studio Development Server. This topic describes each of the Web servers and how to select the server to test with.

The following table provides summary guidance for choosing a Web server in Visual Web Developer.

Web server

When to use

IIS Express

Use when the target Web server is IIS 7 but you do not want to (or cannot) use the full version of IIS 7. This requires Visual Studio 2010 Service Pack 1, and IIS Express must be installed separately. IIS Express hosts sites in a manner that is very similar to IIS 7.

Visual Studio Development Server

Use when you are working with an existing project or your site targets an older version of IIS, such as IIS 6, and it is not very important that your testing environment match the production environment closely. This server option is the default in Visual Studio. However, the Visual Studio Development Server runs in a different security context than full IIS, and may fail to reveal errors that can occur when you deploy to a production version of IIS.

IIS

Use when you want to test your Web application using the server environment that is closest to what the live site will run under, and it is practical for you to install and work with IIS on your development computer. However, it can be more complex to configure debugging and other tasks than if you use IIS Express or the Visual Studio Development Environment. Requires you to run Visual Studio as an administrator.

Important noteImportant

If you use IIS Express or the Visual Studio Development Server, it is recommended that you test your application on the target IIS server before deploying it to a live site.

By default, Visual Studio 2010 SP1 uses the Visual Studio Development Server for Web site projects and Web application projects. However, you can use IIS Express instead. (For Web application projects, you can use IIS.) For more information, see How to: Specify the Web Server for Web Projects in Visual Studio.

IIS Express includes many of the features of IIS 7 Web server without requiring you to install and manage IIS 7 on your computer. Because IIS Express is similar to IIS 7, it lets you transition Web sites to IIS more smoothly than the built-in Visual Studio Development Server does.

NoteNote

Support for IIS Express was introduced in Visual Studio 2010 Service Pack 1.

IIS Express offers the following features:

  • It supports and enables the same extensibility model and Web.config file settings as IIS 7.

  • It does not require changes in your Web application code.

  • It can be installed side-by-side with the full IIS web server as well as with the Visual Studio Development Server. You can choose a different Web server for each project.

In corporate environments, IIS Express offers the following features:

  • It does not require an administrator account in order to run or debug applications.

  • It does not serve requests to a browser on another computer, making its approval easier in corporate environments.

  • It supports multiple developers on the same computer. Configuration files, settings, and Web content are maintained on a per-user basis under the %systemdrive%\users\<username> folder.

  • It can be installed on versions of Windows that do not support IIS 7.

TipTip

Although IIS Express is derived from IIS and supports the core features of IIS, there are some differences between these servers. For more information, see IIS Express Overview.

IIS Express Requirements

To install IIS Express in your computer, you must have the following:

  • Windows XP, Vista, or Windows 7, or Windows Server 2008 or 2008 R2.

  • The .NET Framework 4 or later.

  • Visual Studio 2010 SP1 or Visual Web Developer 2010 Express SP1.

Installing IIS Express

IIS Express is not installed automatically as part of Visual Studio 2010 SP1. To install IIS Express, you can use the Microsoft Web Platform Installer.

To install IIS Express in Visual Studio 2010 SP1

  1. In a browser, go to the installation page of the Microsoft.com/Web site.

  2. Download the installer and then follow the steps to finish the installation.

To make IIS Express the default Web server for all Web projects in Visual Studio 2010 SP1, see How to: Specify the Web Server for Web Projects in Visual Studio.

Using the IIS Express System Tray Application

IIS Express starts automatically when you run a project in Visual Studio, and it stops when you close the Web site or Web application project in Visual Studio. When IIS Express is running, it displays an icon in the system tray.

The following table lists typical tasks for IIS Express and how to perform them.

Task

Steps

Display a list of all sites that are running on IIS Express

Right-click the IIS Express icon in the system tray, and then click Show All Applications.

View a Web site directory location, configuration path, and .NET Framework version

Select the Web site in the IIS Express window. The information will appear beneath the list of Web sites.

Stop IIS Express

Right-click the tray icon and select Exit.

NoteNote
In most cases, you do not have to shut down IIS Express manually. However, if you are using SQL Server Express, you might have to stop IIS Express manually before you can access a SQL Server Express .mdf file (for example, from SQL Management Studio).

If you do not want to use IIS Express or IIS as your Web server, you can use the Visual Studio Development Server. If you are working with a file-system Web site or a Web application project, by default Visual Studio automatically uses the Visual Studio Development Server. The Visual Studio Development Server is a Web server that runs locally on Windows operating systems, including Home Edition versions. As with IIS Express, it is specifically built to run ASP.NET on the local computer. It will not serve requests to another computer. Additionally, it will not serve files that are outside the application scope. The Visual Studio Development Server is one way to test your Web site or application locally before you publish it to a production server running IIS. However, if the production server that you will be publishing to is IIS 7 or a later version of IIS, you should use IIS Express because it is functionally closer to IIS 7.

The Visual Studio Development Server does not include all of the extra facilities of IIS. For example, like IIS Express, the Visual Studio Development Server does not support SMTP or FTP. If your Web project involves sending email messages, you must have access to an IIS SMTP virtual server to test email.

When you test a file-system Web site using the Visual Studio Development Server, static files such as images and style sheets are subject to ASP.NET authorization. For example, Visual Studio Development Server will not serve static files in a file-system Web site if they are in a folder that restricts anonymous users from accessing it and if you are testing the site as an anonymous user.

When you create a new file-based Web site or Web application project, a random port is selected for the project. For example, if you are testing a page called ExamplePage.aspx, when you run it on IIS Express or the Visual Studio Development Server, the URL of the page might be:

http://localhost:31544/ExamplePage.aspx

If you want to run IIS Express or the Visual Studio Development Server on a specific port, you can configure the server to do so. You might do this in these scenarios:

  • You have copied a Web application project or Web site project and you want to debug and work on both simultaneously. In that case you will have a port collision and will need to change the port number for one of the projects.

  • Your project includes a reference to a client project or Web service that is bound to a specific port.

  • The code in your project listens to a specific port and you want to be able to test the application using IIS Express or the Visual Studio Development Server.

For more information, see How to: Specify a Port for the Development Server.

An important difference between the development servers in Visual Studio and IIS is the security context in which the servers run your ASP.NET pages. This difference can be a source of problems when you deploy a Web site or Web application to run on IIS.

When you run a page using IIS Express or the Visual Studio Development Server, the page runs in the context of your current user account. For example, if you are running as an administrator-level user, a page running in the Visual Studio Development Server will have administrator-level privileges. In contrast, in IIS 7, by default ASP.NET runs in an account that has limited privileges. For more information, see Application Pool Identities on the IIS.net Web site.

If you are simply reading and running the code in ASP.NET pages, this difference is not very important. However, the different security contexts for the two Web servers can affect your testing of the following:

  • Database access   When you work with IIS Express or the Visual Studio Development Server, you can typically use Windows Integrated authentication to access SQL Server. However, when the same page runs in IIS, the page will be running in the context of the application pool identity. You can either use SQL Server authentication instead or add the application pool identity that the page runs under as a SQL Server login. For more information, see Accessing SQL Server from a Web Application, ASP.NET Security Architecture, and Application Pool Identities.

  • Code access security   If your page runs in medium trust (as most Web hosting providers require), the page might run differently under the server in Visual Studio than it does in IIS.

  • Access to other resources that the page requires   This can include reading and writing files other than Web pages, reading and writing the Windows registry, and so on.

The production Web server for Microsoft operating systems is IIS, which can include a Web server, File Transfer Protocol (FTP) server, Simple Mail Transfer Protocol (SMTP) virtual email server, and other facilities. In order to run IIS, you must be working with one of the versions of Windows that is listed in the following table.

Windows version

IIS version

Windows Server 2008 R2

Windows 7 (Home Premium, Professional, Enterprise, and Ultimate editions)

IIS 7.5

Windows Server 2008

Windows Vista (Home Premium, Business, Enterprise, and Ultimate editions)

IIS 7.0

Windows Server 2003

Windows XP Professional x64

IIS 6.0

Windows XP Professional x32

IIS 5.1 (not recommended; use IIS Express instead. For more information, see Using IIS Express earlier in this topic.)

Advantages of Using IIS as a Development Server with Visual Studio

Working directly with IIS as your development Web server lets you work in an environment much closer to that of an IIS production Web server. This can help you solve configuration problems before your project goes live. If you use IIS Express or the built-in Visual Studio Development Server, the transition to an IIS production Web server might require you to perform extra configuration tasks because of the different security contexts between test and production servers.

Disadvantages of Using IIS as a Development Web Server

Using IIS as a development server can require more setup and configuration tasks in order to work with Visual Studio than using IIS Express or the Visual Studio Development Server, including the following:

  • Both IIS and ASP.NET must be enabled in Windows, and ASP.NET must be registered with Windows. (Registration is a separate step if you installed the .NET Framework first, and then enabled IIS. For more information, see ASP.NET IIS Registration Tool (Aspnet_regiis.exe).)

  • You must run Visual Studio as an administrator in order to work with IIS.

  • To debug web projects, Windows Authentication must be enabled in IIS.

In addition, it might be impractical for you to work with IIS if any of the following apply:

  • Your corporate workplace policy does not allow server roles like IIS to be enabled on developer computers.

  • Your corporate workplace policy does not allow developers to have administrator accounts on IIS.

  • You are developing ASP.NET Web pages while working with a Home Edition of Windows, which does not support IIS.

  • You do not want to host a Web server on your computer (for example, on your home network) for security reasons.

In these cases you can use either IIS Express or the Visual Studio Development Server.

Installing and Configuring IIS to Work with Visual Studio

In Windows XP, Windows Server 2003, and later versions of Windows, IIS is not installed by default. To configure IIS to work with Visual Studio, see the following resources. If you want to install IIS 7, you can download Web Platform Installer and use it to install the IIS 7 Recommended Configuration. This will enable both IIS and ASP.NET (but not Windows authentication) on your computer.

For more information about working with IIS, see the following topics:

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.