Hi Im upgrading a DW8 to DW 9.6.1
Im using Global.asax in DW8 to do a number of things on application start. I understand in DW9 you can't modify Global.asax. Am I correct that you can use a notification subscriber
to hook Application_Start and Application_End, if so which are the best subscribers to achive my solution?
BeforeStart
AfterDynamicwebStart
BeforeBeginRequest
BeforeEndRequest
Application_Start is only run once, on IIS start, when I log the application in to a remote network folder to access assets (Files / images etc)
public static Web.Library.Methods.AssetManager.NetworkDrive AssetsNetworkDrive = new Web.Library.Methods.AssetManager.NetworkDrive();
string NetworkCDNDrive = ConfigurationManager.AppSettings["NetworkCDNDrive"];
string NetworkAssetsFolder = ConfigurationManager.AppS......... etc
CompilationSection configSection = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
// Log on to a network drive with credentials to create/get etc assets
protected void Application_Start(object sender, EventArgs e)
{
int result = AssetsNetworkDrive.MapNetworkDrive(@"" + NetworkCDNDrive + "", NetworkDriveLetter, ""+ NetworkUserName + "", ""+ NetworkPassword + "");
AssetsNetworkDrive.NetworkDriveName = NetworkCDNDrive;
AssetsNetworkDrive.AssetFolder = NetworkAssetsFolder;
AssetsNetworkDrive.DriveLetter = NetworkDriveLetter;
Web.Library.CustomException.Exception.SetException("Application has started. Map Network Drive Result = " + result + " (Build: "+ Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")", EventLogEntryType.Information);
// Create Styles and script bundles for release or development site versions:
if (configSection.Debug)
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
else
{
BundleConfigRelease.RegisterBundles(BundleTable.Bundles);
}
Dynamicweb.Frontend.GlobalAsaxHandler.Application_Start(sender, e);
}
On Application_End I log out the user (the DW application)
I use the System.Web.Optimization BundleCollection to assemble my bundles which are the minified versions for release, this really speeds up the page.
So in the Master templates I use @Styles.Render("~/bundle/site") or @Scripts.Render("~/bundle/scriptLibraries")
Is this the correct approach for a DW9 to achieve this?
Rgds Kevin