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")"/>
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")"/>
Does anyone know why this is happening? Is this a bug, or I'm missing something?
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");}
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
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
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With