I have dev an MVC app and deployed it to my local IIS as I am using dev server to dev.
我已经开发了一个MVC应用程序并将其部署到我的本地IIS,因为我正在使用dev server to dev。
This is on Vista Ultimate.
这是在Vista Ultimate上。
When i browse the site all the images are not showing and also the login page is displayed.
当我浏览网站时,所有图像都没有显示,并且还显示登录页面。
what would be causing the images not to show and also why the login page showed when I have not set up security in web.config?
什么会导致图像不显示,以及当我没有在web.config中设置安全性时登录页面显示的原因?
I tried to see if the ASPNET account had permissions but there is user of that name and there is no Add option in properies either.
我试图查看ASPNET帐户是否具有权限,但是有该名称的用户,并且在该属性中也没有添加选项。
Malcolm
2 个解决方案
#1
This could be a deployment issue, rather than a permissions issue. Did you try to browse directly to an image via your browser?
这可能是部署问题,而不是权限问题。您是否尝试通过浏览器直接浏览图像?
So if you have an image located in your project as
因此,如果您的项目中有一个图像
\images\login.png
open in your browser to:
在浏览器中打开:
http://hostname/images/login.png
If this works, then you have got a referencing problem in your html. From memory, most images in asp.net mvc are located with:
如果这样可行,那么你的html中就会出现引用问题。从内存来看,asp.net mvc中的大多数图像位于:
src="../../images/login.png"
This could break down if your pathing is different to the current location. I usually prefer this:
如果您的路径与当前位置不同,这可能会中断。我通常喜欢这个:
src="/images/login.png"
or even better:
甚至更好:
src="<%= ResolveUrl("~/images/login.png")%>"
#2
I had a problem with images displaying in an MVC app until I coded the image tags like this:
我在MVC应用程序中显示图像时出现问题,直到我对图像标记进行编码,如下所示:
<img src="<%= Uri.Content("./content/images/image.png") %>" alt="text" />
#1
This could be a deployment issue, rather than a permissions issue. Did you try to browse directly to an image via your browser?
这可能是部署问题,而不是权限问题。您是否尝试通过浏览器直接浏览图像?
So if you have an image located in your project as
因此,如果您的项目中有一个图像
\images\login.png
open in your browser to:
在浏览器中打开:
http://hostname/images/login.png
If this works, then you have got a referencing problem in your html. From memory, most images in asp.net mvc are located with:
如果这样可行,那么你的html中就会出现引用问题。从内存来看,asp.net mvc中的大多数图像位于:
src="../../images/login.png"
This could break down if your pathing is different to the current location. I usually prefer this:
如果您的路径与当前位置不同,这可能会中断。我通常喜欢这个:
src="/images/login.png"
or even better:
甚至更好:
src="<%= ResolveUrl("~/images/login.png")%>"
#2
I had a problem with images displaying in an MVC app until I coded the image tags like this:
我在MVC应用程序中显示图像时出现问题,直到我对图像标记进行编码,如下所示:
<img src="<%= Uri.Content("./content/images/image.png") %>" alt="text" />