切换Visual Studio中使用本地IIS服务器,形象及风格文件后未找到 [英] After switching Visual Studio to use local IIS server, image and style files not found

查看:143
本文介绍了切换Visual Studio中使用本地IIS服务器,形象及风格文件后未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了我的网站的属性在Visual Studio 2010中为使用本地IIS Web服务器,而不是在Visual Studio开发服务器,并单击创建虚拟目录。

I changed my website properties in Visual Studio 2010 to "Use local IIS Web Server" instead of the Visual Studio Development Server, and clicked "Create Virtual Directory".

现在,当我在本地主机来查看网站我的图片和样式都没有发现。在该网站的路径是相对的。 404消息称物理路径为C:\\的Inetpub \\ wwwroot的,这是不是应用程序根目录。如果我复制我的形象和风格文件夹到C:\\的Inetpub \\ wwwroot文件,则显示图像

Now my images and styles are not found when I view the website in localhost. The paths in the website are relative. The 404 message says the physical path is "C:\inetpub\wwwroot", which is not the application root. If I copy my image and style folders into "C:\inetpub\wwwroot" then the images appear.

我错过了一些配置设置,以确保静态文件来自于应用程序,而不是wwwroot文件?

Have I missed some configuration setting to ensure static files come from the application rather than the wwwroot?

推荐答案

您需要检查在IIS中的应用程序。默认网站默认为指向 C:\\的Inetpub \\ wwwroot文件默认情况下。如果您的网站是一个虚拟目录,而不是在IIS中的应用程序(如的http://本地主机/ yoursite ,而不是的http://本地主机: 6000 )和你引用使用URL这样的静态文件: /images/file.jpg ,那么IIS将寻求在wwwroot文件夹对于这些文件。

You'll need to check the application in IIS. The default website defaults to pointing to c:\inetpub\wwwroot by default. If your site is a virtual directory rather than an application in IIS (e.g. http://localhost/yoursite as opposed to http://localhost:6000) and you are referencing your static files using URLs like this: /images/file.jpg, then IIS will be looking in the wwwroot folder for those files.

我想手动在IIS中创建一个新的网站,在你的应用程序的根文件夹指向,您所选择的端口上,然后回到你的设置页面中的Visual Studio和更新端口号。

I would manually create a new website in IIS, pointing at your application's root folder, on a port of your choosing, and then go back to your settings page in Visual Studio and update the port number.

请确保您的网站是在自己的权利的网站,而不是一个目录挂在默认网站。这更像是如何将真实环境反正进行设置。

Make sure that your site is a Site in its own right and not a directory hanging off the Default Website. That's more akin to how it will be set up in your live environment anyway.

这篇关于切换Visual Studio中使用本地IIS服务器,形象及风格文件后未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆