加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – 无法从Orchard模块中的项目文件夹加载图像

发布时间:2020-12-16 07:16:30 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试在我的Orchard模块中插入图像,但我遇到了一些问题. img src="@Href("~/Modules/Orchard.Slider/Content/img/other.jpg")"/ 在我看来,我写了thibut图像没有加载,它说没有找到资源. 但是,如果我将我的图片放在Orchard.Users模块文件夹中,它正在工作
我正在尝试在我的Orchard模块中插入图像,但我遇到了一些问题.

<img  src="@Href("~/Modules/Orchard.Slider/Content/img/other.jpg")"/>

在我看来,我写了thibut图像没有加载,它说没有找到资源.
但是,如果我将我的图片放在Orchard.Users模块文件夹中,它正在工作:

<img  src="@Href("~/Modules/Orchard.Users/Content/img/other.jpg")"/>

有谁知道为什么会这样?这是一个错误,还是我错过了什么?

只是添加,当我第一次尝试构建相同的模块时,我正常从我的文件夹中加载图像(使用第一行代码),但我无法包含css文件,因为

@{Style.Include("slider_style.css");}

没有生产任何东西.事实并非如此,我的html源码中有’资源未找到的东西’ – 考虑到包含slider_style.css,没有任何一行

然后我再次创建了相同的项目,现在我可以包含css,但无法加载图像.问题是我只是复制/粘贴代码,只有改变就是我
实际上是一个新的Orchard模块项目和新的.cs和cshtml.文件.

提前致谢,
斯特凡

解决方法

尝试将以下web.config文件放在img文件夹中.

<?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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读