https://msdn.microsoft.com/en-us/library/58wxa9w5(v=vs.120).aspx

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), External Hosts, or Custom Web Servers.

You can use any of these web servers with a file-based web application project.

For a file-based web site project, you can use IIS Express.

This topic describes each of the web servers and how to select a web server for testing.

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

(1)IIS Express
IIS Express is the default web server for web application projects in Visual Studio 2012 and Visual Studio 2013, and it is recommended for both web application projects and web site projects.

(2)Local IIS

Use IIS 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.

For more information, see Disadvantages of Using IIS as a Development Server with Visual Studio later in this topic.

You can use IIS with web application projects, but not with web site projects.

(3)External Host

You can specify the URL of an external host that you will use for testing.

For more information, see Advantages of using an External Host as a Development Server with Visual Studio later in this topic.

(4)Custom Web Server

Visual Studio 2013 adds support for specifying custom Web servers in your projects;

this functionality enables developers to define the environment for testing their Web applications.

IIS Express is designed to emulate模仿 IIS, but minor differences between IIS Express and the full version of IIS may result in errors that occur only after you have deployed your website to a production version of IIS.

For more information, see Disadvantages of Using IIS Express later in this topic.

If you use IIS Express, it is recommended that you test your application on a staging server that uses the target version of IIS before deploying it to a live site.

Specifying the Web Server for a Visual Studio Web Project

By default, Visual Studio 2012 and Visual Studio 2013 use IIS Express.

For more information about about how to specify one of the alternative web servers, see How to: Specify the Web Server for Web Projects in Visual Studio.

Using IIS Express with Visual Studio

IIS Express includes many of the features of IIS 7 and IIS 8 web servers without requiring you to install and manage IIS on your computer.

Because IIS Express is similar to IIS 7 and IIS 8, it lets you transition web sites to IIS more smoothly than using other Web servers.

IIS Express offers the following features:

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

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

  • It can be installed side-by-side with the full version of IIS and other web servers. 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 can be installed on versions of Windows that do not support IIS 7 or IIS 8.

Tip

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, and Disadvantages of Using IIS Express later in this topic.

Installing IIS Express

IIS Express is installed automatically when you install Visual Studio 2012 and Visual Studio 2013.

If you want to install IIS Express in Visual Studio 2010 (SP1 is required), you can use the Microsoft Web Platform Installer.

To install IIS Express

  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.

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 project or web application project in Visual Studio.

When IIS Express is running, it displays an icon in the system tray, as shown in the following illustration.

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

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.

Note:

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 Server Management Studio).

Changing the Port for IIS Express

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, the URL of the page might be:

http://localhost:31544/ExamplePage.aspx

If you want to run IIS Express 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.

Disadvantages of Using IIS Express

(1)Resolving References to Root-Level Resources when Deploying to Production

If your code references root-level resources such as CSS and JavaScript files without specifying that they are at the project root level,

the application might work correctly when you test in Visual Studio but fail when you deploy it to IIS in production.

Depending on how IIS is configured, a failure could happen in production because IIS may look for root level resources in the root of the IIS web site.

For example, if you create a new MVC project in Visual Studio, you’ll find this line of code in the Views\Shared\_Layout.cshtml file:

@Styles.Render("~/Content/css")

The tilde (~) specifies that this resource is at the root level of the application.

If you remove the tilde and run the application in Visual Studio with IIS Express, you see no change in the application appearance:

But when you deploy to IIS (or select IIS as the development web server in Visual Studio), you may see that CSS styling is lost because IIS can’t find the resource:

(2)Security Context for IIS Express

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, 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 IIS Express will have administrator-level privileges.

In contrast, in IIS 7 and IIS 8, ASP.NET runs as an account that has limited privileges by default.

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 in several ways:

  • Database access   When you work with IIS Express, 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 ApplicationASP.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.

未完,剩余部分可以直接在msdn官网上查看

这里省略了后2种Server

Using IIS with Visual Studio

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 Server 2008 R2  ,Windows 7 (Home Premium, Professional, Enterprise, and Ultimate editions)    对应   IIS 7.5

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 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, 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, 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.

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.

  • Your web project uses a SQL Server Express LocalDB database. For more information, see Using LocalDB with Full IIS on the SQL Server Express blog.

In this case you can use IIS Express.

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.

If you have Windows Server 2012 or Windows 8 and you want to install IIS 8, see Installing IIS 8 on Windows Server 2012 on the IIS.net site, orInstall IIS 8 and ASP.NET Modules on the TechNet site.

If you have Windows Server 2008 or Windows 7 and you want to install IIS 7, you can download the Web Platform Installer and use it to install the IIS 7 Recommended Configuration.

This will enable both IIS and ASP.NET on your computer.

For more information about how to use IIS 7 with Visual Studio, see Running Web Applications on Windows Vista with IIS 7.0 and Visual Studio or Running Web Applications on Windows Server 2008 with IIS 7.0 and Visual Studio.

If you are using Windows Server 2003 and you want to install IIS 6, see Installing IIS (IIS 6.0) on the Microsoft Technet site.

See also How To Enable Extensions Used by Visual Studio .NET in IIS 6.0 and How to: Create and Configure Local ASP.NET Web Sites in IIS 6.0.

Web Servers in Visual Studio for ASP.NET Web Projects的更多相关文章

  1. 使用 Visual Studio 将 ASP.NET Web 应用部署到 Azure

    原文地址:https://www.azure.cn/zh-cn/documentation/articles/web-sites-dotnet-get-started 配置新的 Web 项目 下一步是 ...

  2. ASP.NET Core 中文文档 第二章 指南(2)用 Visual Studio 和 ASP.NET Core MVC 创建首个 Web API

    原文:Building Your First Web API with ASP.NET Core MVC and Visual Studio 作者:Mike Wasson 和 Rick Anderso ...

  3. 用于 Visual Studio 和 ASP.NET 的 Web 应用程序项目部署常见问题

    https://msdn.microsoft.com/zh-cn/library/ee942158(v=vs.110).aspx#can_i_exclude_specific_files_or_fol ...

  4. 【转载】保哥 釐清 CLR、.NET、C#、Visual Studio、ASP.NET 各版本之間的關係

    我常常不仅仅逛 博客园,还会去找国外,特别是台湾的技术部落格,发现好的文章,我便会收录,今天我转载或者全文复制,在Google 博客园,一位叫保哥, 釐清 CLR..NET.C#.Visual Stu ...

  5. Working with Data » 使用Visual Studio开发ASP.NET Core MVC and Entity Framework Core初学者教程

    原文地址:https://docs.asp.net/en/latest/data/ef-mvc/intro.html The Contoso University sample web applica ...

  6. Visual Studio 2010 中的 Web 开发

    概述 Microsoft Visual Studio 2010 为 ASP.NET Web 应用程序的开发提供非常多新的功能.这些新功能旨在帮助开发者高速方便地创建和部署质量高且功能全的 Web 应用 ...

  7. 【翻译】使用Visual Studio创建Asp.Net Core MVC (一)

    This tutorial will teach you the basics of building an ASP.NET Core MVC web app using Visual Studio ...

  8. Visual Studio 2017 ASP.NET Core开发

    Visual Studio 2017 ASP.NET Core开发,Visual Studio 2017 已经内置ASP.NET Core 开发工具. 在选择.NET Core 功能安装以后就可以进行 ...

  9. 使用Visual Studio 创建新的Web Part项目

    使用Visual Studio 创建新的Web Part项目 Web Part是你将为SharePoint创建的最常见的对象之中的一个.它是平台构建的核心基块. 1. 管理员身份打开Visual St ...

随机推荐

  1. Poj 1222 EXTENDED LIGHTS OUT

    题目大意:给你一个5*6的格子,每个格子中有灯(亮着1,暗着0),每次你可以把一个暗的点亮(或者亮的熄灭)然后它上下左右的灯也会跟着变化.最后让你把所有的灯熄灭,问你应该改变哪些灯. 首先我们可以发现 ...

  2. 【BZOJ】【1293】【SCOI2009】生日礼物

    二分/堆 求一个最小的区间使得包含所有的颜色(并不一定只出现一次)$n\leq 10^6$ 我想的做法是:二分这个最小的长度(满足单调性……好久才想到QAQ),然后O(n)判断是否有可行的区间,这一步 ...

  3. Nodejs Express 4.X 中文API 3--- Response篇

    相关阅读: Express 4.X API 翻译[一] --  Application篇 Express4.XApi 翻译[二] --  Request篇 Express4.XApi 翻译[三] -- ...

  4. [转]日期格式化(yyyy-MM-dd)中,为什么 M 多大写?

    最近犯了个可傻逼的错误,格式化年月日的时候不小心将yyyy-MM-dd写成YYYY-MM-dd,导致格式化结果中年不正确. 看看知乎上的说法 问题: http://www.zhihu.com/ques ...

  5. ibatis的iterate使用

    Iterate:这属性遍历整个集合,并为 List 集合中的元素重复元素体的内容. Iterate 的属性:       prepend  - 可被覆盖的 SQL 语句组成部分,添加在语句的前面(可选 ...

  6. jQuery1.9.1--结构及$方法的工作原理源码分析

    jQuery的$方法使用起来非常的多样式,接口实在太灵活了,有点违反设计模式的原则职责单一.但是用户却非常喜欢这种方式,因为不用记那么多名称,我只要记住一个$就可以实现许多功能,这个$简直就像个万能的 ...

  7. mysql同时修改2个表思路

    1.需求:修改评论表中的昵称为手机号码最后4位. ,) AND issuer_name LIKE '1%'; 2.由于误操作(MID(issuer_name,4,6)是中间的6位),需要数据回滚. 3 ...

  8. struts.properties的参数描述

    A.2.1 概述 如果我们希望覆盖在default.properties文件里面定义的默认配置,那就可以定义struts.properties文件,在里面设置我们需要的值,当然现在也可以在struts ...

  9. java+内存分配及变量存储位置的区别[转]

    原文来自:http://blog.csdn.net/rj042/article/details/6871030#comments Java内存分配与管理是Java的核心技术之一,之前我们曾介绍过Jav ...

  10. SQL注入攻击

    SQL注入攻击是黑客对数据库进行攻击的常用手段之一.随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多.但是由于程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候, ...