无法从项目文件夹中的果园模块加载图像 [英] Can't load image from project folder in Orchard module
问题描述
我想在我的果园模块插入图像,但我有一些问题。
I'm trying to insert a image in my Orchard module, but I'm having some problems.
<img src="@Href("~/Modules/Orchard.Slider/Content/img/other.jpg")"/>
在我看来,我写thibut图像不加载,它说,资源是找不到的。
但是,如果我把我的照片在Orchard.Users模块文件夹,它是工作:
In my view i wrote thibut the image is not loading, it says that resource is not found. However, if I put my picture in Orchard.Users module folder, it is working:
<img src="@Href("~/Modules/Orchard.Users/Content/img/other.jpg")"/>
有谁知道为什么发生这种情况?这是一个bug,或者我失去了一些东西?
Does anyone know why this is happening? Is this a bug, or I'm missing something?
我想补充,当我试图建立同一模块的第一次,我装形象从我的文件夹一般(与code的第一行),但我不能包括CSS文件,
Just to add, that when I tried to build the same module for the first time, I loaded image from my folder normally (with the first line of code), but I couldn't include css file, as
@{Style.Include("slider_style.css");}
没有产生任何东西。这并不是说我在我的html源代码,用资源未找到事的情况 - 有不考虑slider_style.css列入任何行
didn't produce anything. It isn't the case that I had in my html source, with the 'resource not found thing' - there wasn't any line considering the inclusion of slider_style.css
然后,我创建了同一项目再次,现在我可以包括CSS,但不能加载图像。问题是,我只是复制/粘贴的code,唯一的变化是我
实际上提出了新的果园模块项目和新的.cs和CSHTML。文件。
Then I created same project again, and now I can include css, but can't load images. The thing is that i just copy/pasted the code, only change was that I actually made a new Orchard module project and new .cs and cshtml. files.
在此先感谢,
斯特凡
Thanks in advance, Stefan
推荐答案
尝试将下面的web.config文件中IMG文件夹中。
Try placing the following web.config file inside the img folder.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<!-- iis6 - for any request in this location, return via managed static file handler -->
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
这篇关于无法从项目文件夹中的果园模块加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!