Unable to view pictures and html pages on server?

Topics: Administration, General
Aug 4, 2014 at 2:57 PM
My website is working fine on local machine but when I upload it on the server. I am unable to view pictures and html pages on server?

For example: , if I go to: www.mydomain.com/myimage.jpg

It gives me error "The resource cannot be found".

The hosting tech support is saying if something needs to be changed or enabled in web config for this ?

Please advise ? The graphics on my site is not being displayed on the website.
Developer
Aug 4, 2014 at 3:00 PM
Could there be a difference in HTTPHandlers installed on your webserver?


Aug 4, 2014 at 3:44 PM
Edited Aug 4, 2014 at 3:46 PM
How to check that?

I am using Arvixe. ASP server. My all other sites like nopCommerce and other asp.net based sites works fine without any problem.

I have full trust level / full permission on the wwwroot folder.
Aug 4, 2014 at 5:04 PM
Now I am getting this message when I am trying to view the image file:
There is no build provider registered for the extension '.png'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'. 
Aug 4, 2014 at 5:47 PM
Edited Aug 4, 2014 at 6:05 PM
The webhosting tech supoport checked the issue and found that due to MVC request handler routing all other requested are returning 404, i.e:
http://mydomain.com/imagefolder/
http://mydomain.com/imagefolder/testimage.png

How you need to handle the file/folders, please check your web.config for below code,

=============================================================================================================
<!-- Return 404 for all requests via a managed handler. The URL routing handler will substitute the MVC request handler when routes match. --> <add name="NotFound" path="" verb="" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script"/>
=============================================================================================================

how to fix it ?
Aug 4, 2014 at 6:12 PM
Edited Aug 4, 2014 at 6:27 PM
The tech support company also said that when they remove webconfig, they are able to view the images. How to solve this issue ?

This means something in webconfig or Orchard project is preventing the images from displaying.
Coordinator
Aug 4, 2014 at 6:30 PM
Check your web.config and the one that is shipped with Orchard by default.
Also, ensure the web.config in the /Media folder and the one from Orchard/Media are exactly the same.

I have two website running fine on Arvixe.
Aug 4, 2014 at 6:35 PM
Edited Aug 4, 2014 at 6:46 PM
Here is my webconfig:

View this: http://codeshare.io/Q94qJ
Aug 4, 2014 at 6:36 PM
In the media 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>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
    </staticContent>
    
    <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>
Aug 4, 2014 at 6:38 PM
Edited Aug 4, 2014 at 6:39 PM
In the project: Modules.Deprecated > Orchard.Media, I see this:
<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <remove name="host"/>
      <remove name="pages"/>
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
    </sectionGroup>
  </configSections>
  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
        <add namespace="System.Linq"/>
        <add namespace="System.Collections.Generic"/>
        <add namespace="Orchard.Mvc.Html"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>
  <system.web>
    <compilation targetFramework="4.5">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </assemblies>
    </compilation>
  </system.web>
</configuration>
Aug 4, 2014 at 6:39 PM
What should I do ? I am using version 1.8.1

Could you please share your webconfigs please ?
Coordinator
Aug 4, 2014 at 7:08 PM
The web.config files I use are already shared, they are in the source code of Orchard, nothing more nothing less.

And re-reading your question, it seems your static file is at the domain root, which is not supported by Orchard with the default web.config. You should place them under your Theme or in /Media
Aug 4, 2014 at 7:16 PM
Ok, I will place all images in "Media" folder.

Where should I place extra css stylesheets and jquery js files what I have included in the project? I places in theme folder but still not able to access the files by going to link.
Coordinator
Aug 4, 2014 at 7:31 PM
In your theme or in /Media. You can include the /Media folder in your solution
Aug 4, 2014 at 9:15 PM
I have google webmaster account and google wants to verify the site by placing their google file on root directly.

But since you are saying, putting any file on root directory is not allowed then how I will verify the site ?
Developer
Aug 4, 2014 at 9:23 PM
You can update the root web.config file by adding back a static file handler that serves the file you want served from the root.
Look for the <httpHandlers> section in <system.web> and the <handlers> section in <system.webserver>.
Both sections will have their entries cleared (using <clear/>). After that line, add back a handler specific to your file, e.g.

IIS6:
<system.web>
    <httpHandlers>
      <!-- iis6 - for any request in this location, return via managed static file handler -->
      <add path="myFile.txt" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
IIS7:
<system.webServer>
    <handlers accessPolicy="Script,Read">
      <!-- Clear all handlers, prevents executing code file extensions or returning any file contents. -->
      <clear/>
      <add name="MyFile" path="myFile.txt" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
      <add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script"/>
      ... the rest...
    </handlers>
  </system.webServer>
Aug 4, 2014 at 9:40 PM
Thank you, it worked :)