在Visual Studio 2015中使用IIS服务器而不是IIS Express

问题描述:

如何将已开发的ASP.Net网站配置为使用IIS服务器,而不是在VS2015中使用IIS Express?

How can we configure our already developed ASP.Net website to use IIS Server instead of using IIS Express in VS2015?

IIS Express是Visual Studio 2015中的默认服务器.我的网站可以在Visual Studio 2012中与ASP.NET Web开发服务器一起正常运行,但是当我在VS2015中运行它时,它不会加载CSS和图像.

IIS Express is the default server in Visual Studio 2015. My website runs fine with ASP.NET web Development server in Visual studio 2012 but when i run it in VS2015 , it does not loads the css and images .

所以,我想用IIS服务器而不是VS2015中的IIS Express来运行它.有人可以帮我吗?

So, i want to run it with IIS Server and not IIS Express in VS2015. Can anyone help me out ?

加载CSS和图像的问题很可能是由于您使用的是路径,而不是Web主机.

The problem with loading the CSS and Images is likely because of the paths you have used, not with the web host.

"/Images/Image1.jpeg"总是在与当前页面相同的位置查找具有Image1.jpg的Image子文件夹.

"/Images/Image1.jpeg" always looks for an Image subfolder with an Image1.jpg in the same place as the current page.

〜/Images/Image1.jpeg"将从站点根目录开始查找带有Image1.jpg的Images文件夹.使用波浪号(〜)也可以解决其他问题(用户控件,文件夹中的页面等).

"~/Images/Image1.jpeg" will look for an Images folder with an Image1.jpg starting from the site root. Using the tilde (~) is going to address other things as well (user controls, pages in folders, etc.

样式表href也是一样.如果要诊断这种资源无法加载"问题,可以使用开发人员工具(IE,Chrome,FireFox/FireBug,Safari都有),然后在网络"选项卡上开始捕获.这将列出对每个资源(图像,css,js等)的请求,以及请求路径和HTTP状态(404(未找到),200(确定)等)的状态.

The same holds true for stylesheet hrefs. If you want to diagnose this kind of "resource failing to load" problem, you can use the developer tools (IE, Chrome, FireFox/FireBug, Safari all have them) and start a capture on the network tab. That will list a request to each resource (image, css, js, etc) and what the request path and HTTP status (404 - not found, 200 - OK, etc) is.

除了上面的内容可以帮助您找到不加载CSS和图像的根本问题之外,您还需要做一些事情.

Aside from the above which is directed to help you find the source problem of not loading CSS and Images, you will have to do a few things.

  • 在本地IIS的默认网站中创建一个指向项目根目录的应用程序.
  • 确保在网站项目属性中正确设置了构建"和开始选项"选项卡.确保使用在本地IIS中创建的URL设置使用自定义Web服务器"值.

到那时,您应该能够开始调试,但是如果您想要一个较不脆弱的程序和更轻松的开发体验,则应该真正考虑转换为Web应用程序.

At that point you should be able to Start Debugging, but you should really consider conversion to a Web Application if you want a less fragile program and an easier development experience.

WS/WAP之间的主要区别- https://msdn.microsoft.com/zh-CN/library/dd547590(v=vs.110).aspx

Key differences between WS/WAP - https://msdn.microsoft.com/en-us/library/dd547590(v=vs.110).aspx

从WS转换为WAP- https://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx

Converting from WS to WAP - https://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx