For handling status code 500 followed below step in web.config file:

    <customErrors mode="off" />

    <httpErrors errorMode="Custom">
        <remove statusCode="500" />
        <error statusCode="500" path="/sitecore/service/500.aspx" responseMode="ExecuteURL" />

In case if I add this part instead of httpErrors getting an internal error

   <customErrors mode="RemoteOnly" defaultRedirect="/sitecore/service/500.aspx"/>


The page cannot be displayed because an internal server error has occurred on server


Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
    <!doctype html>
   <html lang="en">
<title>An Error Occurred</title>
<h1>An Error Occurred</h1>
<h4>Our server couldn't complete your request.
    <br />
    Please refresh your browser and try again soon.
<a href="/">Home</a>
    Error Code: 500

please advice better approach to handling this scenario.

  • Little unclear if you get the error only when you add the second section? Also, what's on the logs? That should tell you what went wrong, Is there an exception on your error page? Aug 22, 2018 at 17:06
  • @jammykam I followed the above-mentioned URL so many steps very confusing .below mentioned approach is very simple and straightforward.
    – sindu
    Aug 22, 2018 at 19:39

1 Answer 1


The error handling for Sitecore 9 is the same as Sitecore 8.x

For me, I like to have my error pages as html pages so that it wont cause a loop if I have a serious issue. Here I remove all the existing code and add my new ones to my custom html files.


    <httpErrors errorMode="Custom" existingResponse="Auto">
        <remove statusCode="403" />
        <remove statusCode="404" />
        <remove statusCode="500" />
        <error statusCode="500" responseMode="Redirect" path="/500.html" />
        <error statusCode="403" responseMode="Redirect" path="/404.html" />
        <error statusCode="404" responseMode="Redirect" path="/404.html" />

I do the same thing in my custom errors. This might be overkill, but lets cover our bases.

    <customErrors mode="On" defaultRedirect="500.html" redirectMode="ResponseRewrite">
        <error statusCode="403" redirect="/404.html" />
        <error statusCode="404" redirect="/404.html" />
        <error statusCode="500" redirect="/500.html" />


And in Sitecore set the Layout Not Found and Item Not Found urls

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <setting name="LayoutNotFoundUrl">
        <patch:attribute name="value">/404.html</patch:attribute>
      <setting name="ItemNotFoundUrl">
        <patch:attribute name="value">/404.html</patch:attribute>


And to go to the next level, you can track your MVC exceptions in a pipeline.

namespace Customer.Foundation.Logging.Pipelines
    using System.Web;
    using System.Web.Configuration;
    using Sitecore.Mvc.Pipelines.MvcEvents.Exception;
    using Sitecore.Diagnostics;
    using Sitecore.Configuration;
    using Customer.Foundation.Logging.Services;

    public class GenericExceptionHandler : ExceptionProcessor
        public override void Process(ExceptionArgs args)
            Log.Error("MVC generic exception processing " + Sitecore.Context.RawUrl, args.ExceptionContext.Exception, this);
            CustomErrorsMode mode = Settings.CustomErrorsMode;

            if (mode == CustomErrorsMode.Off
                // to show details to Sitecore admins: || SC.Context.User.IsAdministrator 
                // to show in the Page Editor: || SC.Context.PageMode.IsPageEditor
                // to show in Preview: || SC.Context.PageMode.IsPreview
                // to show in the debugger: || SC.Context.PageMode.IsDebugging
                || (mode == CustomErrorsMode.RemoteOnly && HttpContext.Current.Request.IsLocal))

            ErrorService errorService = new ErrorService();

            Sitecore.Web.WebUtil.RedirectToErrorPage("An error has occurred");
            args.ExceptionContext.ExceptionHandled = true;

An that is brought together with a patch config.

            <processor type="Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer, Sitecore.Mvc">
                <patch:attribute name="type">Customer.Foundation.Logging.Pipelines.ExecuteRenderer, Customer.Foundation.Logging</patch:attribute>
  • when I try the ExceptionProcessor I get a error "Sitecore.Exception.Handler.Pipelines.Response.RenderRendering.RenderRendering.ExecuteRenderer" No matching constructor was found." do you know this problem? Aug 8, 2019 at 8:54
  • @squadwuschel Yes, you must include some constructors. Something like public ExecuteRenderer() { } and public ExecuteRenderer(Rendering.IRendererErrorStrategy errorStrategy) :base(errorStrategy) { } Jun 5, 2020 at 17:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.