private void RewriteCMSPath(HttpContext context, string sTmplateFile, string sQuery)
{
try {
if (string.IsNullOrEmpty(sVirtualReqFile)) {
sVirtualReqFile = SiteData.DefaultDirectoryFilename;
}
if (string.IsNullOrEmpty(sTmplateFile)) {
sTmplateFile = SiteData.DefaultTemplateFilename;
}
context.RewritePath(sVirtualReqFile, string.Empty, sQuery);
//cannot work in med trust
//Page hand = (Page)PageParser.GetCompiledPageInstance(sFileRequested, context.Server.MapPath(sRealFile), context);
Page hand = (Page)BuildManager.CreateInstanceFromVirtualPath(sTmplateFile, typeof(Page));
hand.PreRenderComplete += new EventHandler(hand_PreRenderComplete);
hand.ProcessRequest(context);
} catch (Exception ex) {
//assumption is database is probably empty / needs updating, so trigger the under construction view
if (DatabaseUpdate.SystemNeedsChecking(ex) || DatabaseUpdate.AreCMSTablesIncomplete()) {
SiteData.ManuallyWriteDefaultFile(context, ex);
} else {
//something bad has gone down, toss back the error
throw;
}
}
}