Include new css in view problem

Topics: Customizing Orchard
Jun 7, 2011 at 10:21 AM
Edited Jun 7, 2011 at 10:39 AM

How do u guys include new css file without modifying TheThemeMachine Layout.cshtml ?

I write this on the top of my view code

Style.Include("base.css");

And it results an error  :  The IControllerFactory 'Orchard.Mvc.OrchardControllerFactory' did not return a controller for the name 'Orchard.TestProject'.

Line 141 , Orchard.Mvc.Routes.ShellRoute

TestProject is my module

Jun 7, 2011 at 11:12 AM

Is base.css in the Styles folder of TestProject? ...And is there a Web.config in that folder (there should be).

Jun 7, 2011 at 11:35 AM
Edited Jun 7, 2011 at 11:38 AM

Yes , I had put it in Styles folder, and web.config is there too

Jun 7, 2011 at 11:48 AM

So if you try to access the stylesheet from the browser (i.e. /Modules/TestProject/Styles/base.css) can you access it ok?

You could just try fully rebuilding the project and see if that clears it up, it's a weird error that I've sometimes seen happen when things are out of sync.

Failing that, the problem must be somewhere else. Does the view display correctly if you remove the style include?

Jun 7, 2011 at 11:55 AM

When I use Style.Include("base.css") , the view display correctly although when I debug , an exception was thrown , not a problem because it is in try-catch block , but it is annoying

And of course if i remove it , the view doesn't display as I want . I have tried to use:  RegisterLink(new LinkEntry{ })  , but it doesn't work , it can't find my css file

The link : Modules/TestProject/Styles/base.css return the same error as Style.Include

I will try to rebuild the project

Jun 7, 2011 at 12:35 PM

Can you post the contents of the Web.config in your Styles folder?

Jun 8, 2011 at 2:34 AM

Here it is

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

Jun 8, 2011 at 10:37 AM

Weird - it should be all fine. You say the base.css is loading correctly from your view though, even if there's a handled exception?

Jun 8, 2011 at 10:44 AM

Yes, all view work properly , but the exception still be thrown out

Jun 8, 2011 at 12:13 PM

Which version of Orchard have you got. Maybe you could try the latest 1.2RC?

Jun 9, 2011 at 11:40 AM

I'm using version 1.1 , may be i will wait for official 1.2

Jun 9, 2011 at 12:09 PM

I've been using 1.2, it seems very stable, and performance is hugely improved over 1.1 - but, if you're not having any other problems, might be safer to wait.

Jun 11, 2011 at 3:22 AM

Yah , thanks for your help