This project is read-only.
Project Description
The MVC Resource Engine library provides components to use resource engines working similar to asp.net mvc view engines. Rather than putting all resources to one place, you can assign them to specific controllers and areas.

How To ...
  • Download the source and the sample project. There is no compiled binary to download, you can compile and modify the code if you want.
  • If you have compiled the MVCResourceEngine.dll you can reference to it from your project.
  • MVC Resource Engine provides UrlHelper extensions, so add the MVCResourceEngine namespace to your pages section in the web.config file, if you start a new project.
  • Now  you can use the resource extension method of the UrlHelper class. Put a file called "Layout.css" to "~/Resources/Shared/" and call the extension method in a view:

    <%: Url.Resource("Layout.css") %>
    
    If the extension method recognizes that a resource called "Layout.css" exists in the shared folder, the virtual path of the resource will be returned. If "Layout.css" doesn't exist an exception will occur.

  • The default resource engine searches in the following locations for the resource:
    ~/Areas/{area}/Resources/{controller}/{resource}
    ~/Areas/{area}/Resources/Shared/{resource}
    ~/Resources/{controller}/{resource}
    ~/Resources/Shared/{resource} 
     
  • You can create your own resource engine by implementing the IResourceEngine interface and replacing the default resource engine with yours:

    ResourceEngines.Engines.Clear();
    ResourceEngines.Engines.Add(new CustomResourceEngine());
    
     

Last edited Jan 27, 2012 at 9:37 AM by Lenne231, version 33