OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

got 500 error for js of child theme #5675

Open infofromca opened 9 years ago

infofromca commented 9 years ago

added this file in child theme

using Orchard.UI.Resources; namespace Guang.BootstrapBase { public class ResourceManifest : IResourceManifestProvider { public void BuildManifests(ResourceManifestBuilder builder) { var manifest = builder.Add(); manifest.DefineScript("myCustom").SetUrl("mycustom.js").SetDependencies("jQuery"); } }

}

then Script.Require("myCustom"); in a .cshtml file in child theme

got this:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

sebastienros commented 9 years ago

Got the same thing yesterday, and figured out why, so this one is easy. Open the project and change the target framework to 4.5.1.

infofromca commented 9 years ago

my all projects have targeted to 4.5.1

infofromca commented 9 years ago

also 500 for favicon.ico

rtpHarry commented 9 years ago

Does your folder have a web.config with a StaticFile handler configured? Something like:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <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>
infofromca commented 8 years ago

customejs500

just retested it with newest 1.x today, the same issue. web.config is no problem

Thierry-S commented 8 years ago

I've had the same problem trying to use Bootstrap theme in Orchard (all using the latest versions directly from github, so even more recent than orchard 1.10 and Bootstrap theme 3.3.5).

To find out the real error under the 500, in the Orchard web.config, comment out the line: <!-- Prevent IIS 7.0 from returning a custom 404/500 error page of its own. --> <!--<httpErrors existingResponse="PassThrough" />-->

Then you can see the real error in the browser by requesting one the individual files in folder Scripts, Content or Styles, for example: http://localhost:30321/OrchardLocal/Themes/PJS.Bootstrap/Content/Swatches/journal_th.png

The error I get is: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'StaticFile' Config File \\?\C:\.......\Orchard-1.10.x- 2440e68\src\Orchard.Web\Themes\PJS.Bootstrap\Content\web.config

<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />

So rtpHarry was on the right track. To fix this, I've added <remove name="StaticFile"/>

above each of the <add name="StaticFile".... in all web.config files in the Bootstrap Theme.

What I don't understand is other themes, such as TheThemeMachine, also have child web.config in subfolder Styles for example, and they don't cause a problem when used. So what other settings somewhere affects this? I'm discussing this on the Bootstrap theme ticket: https://github.com/psenechal/PJS.Bootstrap/issues/12

donaldboulton commented 8 years ago

Fixed it NOW it works with Orchard 1.9.3 or 1.10 or dev build from today. Fully tested Zip file with fixed PJS.Bootstrap for 1.10 adding JetBrains.Annotations also you should add it to Orchard with package manager. ZIp file for PJS.Bootstrap

Read below as this is how you fix old modules also.

Add PJS.Bootstrap as a new project in VS. 1.0 or dev and look at the references. Core and Framework have old references MVC is version 4.0.0.0. Remove then add correct ones. For MVC just remove MVC reference then use package manager to add MVC 5.3.0 and it will add MVC and the other updated correct assemblies for PJS.Bootstrap not Orchard PJS.Bootstrap.csproj is outdated Change `<?xml version="1.0" encoding="utf-8"?>

` To new Tools Version ` ` add ` ` then copy packages.config from any module to root of PJS.Bootstrap. ` ` Change root web.config from `` to `` `` Update PJS web.config to 4.5.2 and MVC 5.2.3 Then use package Manager Add JetBrains.Annotations After installation you should have in root package file. The above is how you would fix old modules also References to core and framework and MVC. Then adding JetBrains.Annotations for some of the modules, as they were built with resharper and you get [UsedImplicitly] and a dead reference to `using JetBrains.Annotations;` Mostly Themes and Old Modules were built having referenced System.Data.DataSetExtensions and it has been removed so add it back adding System.Web.Entity `` which needs ``