我想为多站点/多语言实现500错误页面,我正在关注this article。
但Global.asax中的Application_Error
未触发。这是我的代码:
<%@ Application Language='C#' Inherits="Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication" %>
<script RunAt="server">
private void Application_Error(object sender, EventArgs e)
{
var customErrorsSection = (System.Web.Configuration.CustomErrorsSection)ConfigurationManager.GetSection("system.web/customErrors");
var lastException = Server.GetLastError();
if (customErrorsSection.Mode != System.Web.Configuration.CustomErrorsMode.Off)
{
try
{
// Log.Error( "There was an error in the application", lastException);
Server.ClearError();
HttpContext.Current.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
Server.Transfer(string.Format("/Error/{0}_500.html", GetSafeLanguage()));
}
catch
{
}
}
}
private string GetSafeLanguage()
{
try
{
return Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName;
}
catch
{
}
return string.Empty;
}
</script>