Render image from module - 404.0 File not found

Topics: Localization, Troubleshooting
Sep 28, 2011 at 5:45 PM

Hi,

I'm trying to adapt the excellent CulturePicker module to enable the site to be toggled between two cultures, based on the user clicking one of two flag images (rather than the default drop down list).

I've added the following code to CulturePicker.cshtml:

@using (Html.BeginForm("ChangeCulture", "UserCulture", new { Area = "Orchard.CulturePicker" })) {
    <div class="changeCulture">
        <input type="image" id="UKflag" src="@Url.Content("~/Modules/Orchard.CulturePicker/Images/UKflag.png")" alt="UK" value="en-GB"/>
        <input type="image" id="ESflag" src="@Url.Content("~/Modules/Orchard.CulturePicker/Images/ESflag.png")" alt="ES"  value="es-ES"/>
    </div>
}

This results in the following html (via Designer Tools):

<form action="/ChangeCulture" method="post">    <div class="changeCulture">
        <input type="image" id="UKflag" src="/Modules/Orchard.CulturePicker/Images/UKflag.png" alt="UK" value="en-GB"/>
        <input type="image" id="ESflag" src="/Modules/Orchard.CulturePicker/Images/ESflag.png" alt="ES"  value="es-ES"/>
    </div>
</form>

For the life of me I can't seem to get the images to render - The Requests log in WebMatrix shows a 404.0 file not found error for both images, but the images are in the right place as per the above paths.

Can anyone point me in the right direction?

Best regards

John

 

Coordinator
Sep 28, 2011 at 5:50 PM

Is there a web.config in that directory?

Sep 29, 2011 at 8:22 AM
Edited Sep 29, 2011 at 8:23 AM

Hello Bertrand,

Thanks for your reply.  No there wasn't, so due to your prompt I've now added this one to the Images directory (for anyone else who's interested):

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

This appears to work, but what I'm not clear on is why a web.config file is required for each folder.  Can you direct me some documentation (I assume this is an MVC thing rather than Orchard specific)?

Thanks for your help.

Best regards

John

Coordinator
Sep 29, 2011 at 8:46 AM

Because we locked down everything by default. You need to unlock what you need, as you need it.

Sep 29, 2011 at 8:56 AM

Ok, well I'll be ready for the next time :)

Thanks very much for your help.