Suggested modification to ease using BE under another portal

Topics: Business Logic Layer
Nov 8, 2010 at 1:11 PM


Moving BlogEngine to a subfolder and using it under a web site doesn't work from scratch, and I suggest some modifications to the source code which, without changing the default behaviours could ease the sub folder move.
This is valid for vertsion

First some changes in source c# code :
// CS ADNT var fileEntries = Directory.GetFiles(HostingEnvironment.MapPath("~/" + pathFromRoot))
var fileEntries = Directory.GetFiles(HostingEnvironment.MapPath("/" + pathFromRoot))

// CS ADNT Utils.AddFolderJavaScripts(this, "Scripts", true);
Utils.AddFolderJavaScripts(this, string.Format("{0}Scripts", Utils.RelativeWebRoot), true);
//CS ADNT Utils.AddFolderJavaScripts(this, string.Format("themes/{0}", this.theme), true);
Utils.AddFolderJavaScripts(this, string.Format("{0}themes/{1}", Utils.RelativeWebRoot, this.theme), true);

// CS ADNT var path = HttpContext.Current.Server.MapPath(file);
var path = HttpContext.Current.Server.MapPath("/"+file);

if ( Utils.IsMono ) // CS ADNT added to say compatible with another url rewritter, we do not need to change the default url
context.RewritePath(url.Replace("Default.aspx", "default.aspx")); // fixes a casing oddity on Mono

// CS ADNT Utils.AddFolderJavaScripts(this.Page, "Scripts", true);
Utils.AddFolderJavaScripts(this.Page,string.Format("{0}Scripts", Utils.RelativeWebRoot), true);

// CS ADNT Utils.AddFolderJavaScripts(this.Page, "Scripts", false);
Utils.AddFolderJavaScripts(this.Page,string.Format("{0}Scripts", Utils.RelativeWebRoot), false);

// CS ADNT Utils.AddFolderJavaScripts(this.Page, "Scripts", false);
Utils.AddFolderJavaScripts(this.Page,string.Format("{0}Scripts", Utils.RelativeWebRoot), false);

The we need some change in master pages

I suggest to create a new base folder nammed \MasterPages
and to move the from \admin to \MatserPages
These pages must also be change to find the menu.ascx and the linked css
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="admin.master.cs" Inherits="Admin.AdminMasterPage" %>
<%@ Register Src="~/admin/menu.ascx" TagName="menu" TagPrefix="uc1" %>
<%@ Import Namespace="BlogEngine.Core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" style="height: 100%;">
<head id="Head1" runat="server">
<title>BlogEngine.NET Admin</title>
<link rel="stylesheet" href="~/admin/style.css" type="text/css" />
<link rel="stylesheet" href="~/admin/colorbox.css" type="text/css" />
<link rel="stylesheet" href="~/admin/tipsy.css" type="text/css" /> // Note here that this css does not exists in ?????
<link rel="shortcut icon" href="~/pics/blogengine.ico" type="image/x-icon" />

The modify each aspx page using the admin masterpages
Replace « ~/admin/admin.master » by « ~/MsterPages/admin.master » (idem pour admin1.master)

Next in each aspx and ascx, replace absolute paths containing « ~/ » by corresponding relatives paths

as in src=«~/main/module.ascx » change for src= » »../module.ascx » 

take the opportunity to change codefile and inherit which contains absolute paths, as the associated cs file is in same folder there are no reasons to include a path

with these modifications, the normal install still works normally.
If you need to move to a subfolder you only need to change the master pages and replace the '~/main' path with '~/YourFolder/main' (change also config.sys as recommended by early install doc.

I hope this will be included in the next version, having not time to do all the path to update the scv.

Best regards

CSADNT wrote Fri at 5:40 PM
Ok, I have done more work on this.
It appear that I don't have to move anything else that pics ... but some code has to be changed to fully and transparently adapt working in a subfolder or not.
Especially there should be an Init Method in Util which could be called from the externaml portal in its own Application_Start.
I will post something more detailled ASAP but my version is and I will move to before commenting.