title: 500 Custom Error Pages
body: <p>I want to implement 500 error page for multi-sites/multi-languages, i am following <a href="https://sitecorecommerce.wordpress.com/2015/10/15/500-error-page-in-your-sitecore-application/" rel="nofollow">this article</a>.</p>
  
  <p>But <code>Application_Error</code> in Global.asax is not firing. Here is my code:</p>
  
  <pre class="lang-csharp prettyprint-override"><code>&lt;%@ Application Language='C#' Inherits="Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorApplication" %&gt;
  &lt;script RunAt="server"&gt;
  
      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;
      }
  &lt;/script&gt;
  </code></pre>