MajorRefactoring
MajorRefactoring

Reputation: 3763

Precompilation of aspx and cshtml pages, but leaving the master or layout pages updateable

Not sure if what I am after here is even achievable with the aspnet_compiler.exe tool, but here goes:

We have a site that we allow users to skin by allowing them to modify master pages - or rather, we don't allow them to modify them directly, we give them a cut down "markup" style language that they can use to modify the html of those pages, so they can essentially "skin" the site to look like their own front end.

I'm keen to try to optimise the site by precompiling the views and the aspx pages. But I want the layout and master pages that those views and pages USE to remain updatable. However, I can't get that to work...

Say we have the following aspx page:

<%@ Page Title="Hello World" MasterPageFile="~/Skinable/Skin.Master" Language="C#" AutoEventWireup="true" CodeBehind="HelloWorld.aspx.cs" Inherits="Project.HelloWorld" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" Runat="server">
    Hello World!
</asp:Content>

Which references the master page file Skin.Master in the Skinable folder. Skin.Master needs to be updatable. Here is what I have tried:

I suspect that the reference to the master page is the problem here - ie, if a page references a master page, then that master page MUST be compiled too if you want to compile the page, but I'm not sure. Am I on a hiding to nothing here?

Upvotes: 19

Views: 619

Answers (1)

Rainhider
Rainhider

Reputation: 836

What if you went about it a different way? What if you 'captured' their html and css changes and then made a new css folder or file for that company? (file is the original(s) plus their changes. Then when the master page is loaded, it pulls from a database what file or folder the company uses and writes that into the css from the master page's c#?

Process would be like:

  • Capture their changes
  • Make a css folder and files just like the original(s) but with their changes
  • Pull from database table of which css file to use.(you'll need to make a mapping table of client->css file)
  • Use Master page c# to write to the html which css file to use.

In essence, this makes the css changes loaded at runtime based on your client and you don't have to worry about the compilation.

We used this process successfully for skinning different colors. Our folder system was like:

  • Default -> Original Css Files
  • Dark theme -> Original with dark changes
  • Blue theme
  • Pink theme etc

Upvotes: 1

Related Questions