Posted on 30/09/2014 12:28:55
Hi Nicolai and Mikkel. Interestingly our client has come up with a suggestion what do you think?:
namespace DwCustomModules.CustomModules
{
public class ContentModuleBase : ContentModule
{
/// <summary>
/// Over-Ride and Seal to prevent over-rides from replacing this method
/// </summary>
/// <returns></returns>
public sealed override string GetContent()
{
try
{
return GetContentWithExceptionHandling();
}
catch(Exception ex)
{
try
{
string errorMessage = string.Format("Unhandled Exception, Build: {0}, URL: {1}",
Assembly.GetExecutingAssembly().GetName().Version.ToString(),
Request.Url);
// Log a fatal error
ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
log.Fatal(errorMessage, ex);
}
catch { ; } // For the time being ignore errors that occur during logging
Response.Redirect(SearchEngineFriendlyURLs.GetFriendlyUrl(Config.Instance.DwErrorPageId), true);
return string.Empty;
}
}
/// <summary>
/// Get Content With Exception Handling
/// </summary>
/// <returns></returns>
public virtual string GetContentWithExceptionHandling()
{
return string.Empty;
}
}
}
and in our module:
[AddInName("CentreSearch")]
public class Frontend : ContentModuleBase
{
public override string GetContentWithExceptionHandling()
{
// Set our Template
Dynamicweb.Rendering.Template template = new Dynamicweb.Rendering.Template("CentreSearch/CentreSearch.htm");
bla.......
}
}