Coder Social home page Coder Social logo

amadiere / mvcmasterlayoutshare Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 9 MB

Small library that helped you share one set of MVC Layout Pages between a variety of different applications.

License: MIT License

C# 5.21% ASP 0.03% JavaScript 94.76%

mvcmasterlayoutshare's Introduction

MVC Master Layout Share

Package information

This package allows you to share MVC Views between different projects / applications that live on the same server. Typically, this might be used on an Intranet where many small applications all live within the same all encompassing look-and-feel. This allows you to create one default Layout.cshtml file (or multiple) that you can call from your client applications. By extension, it also allows you to share other content, such as images, scripts & stylesheets (but hey, you could just link to them before anyway...)

Source Code

For more information on the project, to see any outstanding bugs and feature implementations you can fork us on GitHub at: https://github.com/Amadiere/MVCMasterLayoutShare

Example

Included are two projects:

  • MVCMasterLayoutShare.Web.Primary : This is a default "Intranet" MVC4 project with minor modifications and an additional theme.
  • MVCMasterLayoutShare.Web.Secondary: This is a default "Empty" MVC4 project with a simple controller & index method which use the theme from the primary project.

Setup & Usage

Master layout project

  • Choose a web application to be your master project. This must be hosted on the same box and you should have a URI to the filesystem root for that project.
  • The project can be an existing project, or one specifically designated for this purpose.
  • All the links to CSS/Scripts must work from other projects (e.g. not using project root of ~/, but things such as /Shared/ or http://.
  • Any view within the master layout project must have: @inherits System.Web.Mvc.WebViewPage at the very top.
  • Any view within the master layout project using part of the @Html helper functions (or others for that matter), should reference the appropriate DLL at the top - e.g. @using System.Web.Mvc.Html.
  • The default MasterLayoutVirtualDirectory is 'Shared'. This can be overriden by creating a setting in the web.config within the secondary projects.

Secondary projects

  • Global.asax.cs should contain the following in the Application_Start:

    MasterLayoutVirtualPathProvider.Register(); ViewEngines.Engines.Add(new MasterLayoutRazorViewEngine());

  • Web.config should contain a setting for the MasterLayoutPath (and if required, for the MasterLayoutVirtualDirectory also):

    <add key="MasterLayoutPath" value="C:\Users\Alex\Code\MVCMasterLayoutShare\MVCMasterLayoutShare.Web.Primary\" />

  • From here, you should be able to reference images, scripts and stylesheets as normal (via the absolute (local or remote) URL), and now, the views. E.g. if you update your _ViewStart.cshtml file to kick things off. You can add something like:

    Layout = "~/Shared/Views/Shared/_Layout.cshtml";

mvcmasterlayoutshare's People

Contributors

amadiere avatar

Watchers

 avatar James Cloos avatar

Forkers

traffordcouncil

mvcmasterlayoutshare's Issues

Provide sample projects showing working system.

Create a simple structure of two MVC4 projects that are able to show usage of the library. Should include multiple examples, including references of external resources such as CSS & Scripts.

Create GitHub page.

Because that's what all the cool kids are doing and I want to be cool. ^.^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.