Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • rob 75 posts 170 karma points
    Nov 24, 2011 @ 17:47
    rob
    0

    the truth about converting an existing site to Umbraco

    I found this information very difficult to discover as most discussions were about new sites or the fact that the folowing is not possible.

    Existing site:

    • C# .Net 4.0
    • All pages inherit from BasePage
    • Nested Master pages are used.
    • Lots of custom user controls

     

    : make a backup 

    this is going to make the original site unable to render

    : change the BasePage to inherit System.Web.UI.MasterPage from System.Web.UI.Page

    build the solution and look for problems with

    Can not cast Page to BasePage

    Change any references along the lines of 

    BasePage basePage (BasePage)Page;

    to

    BasePage basePage (BasePage)Page.Master;

    User, User.Identity, Page.User, this.User etc

    just find a convenient place to add

    System.Security.Principal.IPrincipal User = HttpContext.Current.User;

    or change uses to use the HttpContext.Current namespace

    MetaKeywords / MetaDescription

    This is the only real pain point, MasterPage has no concept of MetaKeywords or MetaDescription, so you can create an Interface with the properties for MetaKeywords / MetaDescription

    Make the BasePage inherit from it and then handle the population of the meta data manually.

    Your solution will build so make sure it does then we can move over to Umbraco.

     

    Assuming you setup Umbraco with all the defaults;

    : Create a new Template for your Base master page.

    : copy in your original base master page code

    : make sure the page directive includes 

    MasterPageFile="~/umbraco/masterpages/default.master"

    and the CodeBehind and Inherits attributes reflecting your original.

    : Make sure you save any changes

     

    Repeat the following for any nested master pages

    : create a new template for your child master page. (right click and Create on the parent template)

    : copy in your original child master page code

    : make sure the page directive includes the MasterPageFile attribute pointing at your parent template (selecting from the drop down will do this)

    and the CodeBehind and Inherits attributes reflecting your original.

    : Make sure you save any changes

    : Create a new Document Type for the page you want to include and ensure "Create template" is checked

    : Open the new Template and carefully copy and paste any code into the relevant content place holders

    : make sure the page directive includes the MasterPageFile attribute pointing at your parent template (selecting from the drop down will do this)

    and the CodeBehind and Inherits attributes reflecting your original.

    : Make sure you save any changes

    : Copy the original solutions .dlls to the umbraco bin folder and support files images/css/js etc to the required location /images /css /js or what ever convention you use.

     

    User controls

    Follow the video http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/developer-introduction/using-net-user-controls on how to add user controls to umbraco

    You do not need to change the .net code just put the files in the correct places (with the right permissions) and add them as Macros.

    This means you remove the standard page Register lines and the original uses in the Templates.

    Finally in Content you can add your new page from the Document Type, then publish and view.

    Once you are happy with the basic premise it becomes second nature and you can add Umbraco Fields to allow editing of the pages content.

     

Please Sign in or register to post replies

Write your reply to:

Draft