1

I have an ASP.NET based API that needs to send http error codes from the server to the client as they occur. I do not wish to send the entire detailed stock error message containing the stacktrace to the user though, a simple "An error occurred" message will do.

The default behavior from IIS is to always send http 500 to non-local clients. I've gotten as far as to be able to send detailed error messages (with the error code); but is it possible to disable the details somehow?

If not, is it possible to add one custom error file I can use for all errors, and still send the specific error code to the client?

bjelleklang
  • 111
  • 3

1 Answers1

0

I actually had the opposite with one of my own MVC applications. I was getting custom error pages rather than the full error. Your application should include a FilterConfig.cs file in the App_Start. This file should appear as follows:

public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
}

When customErrors is on, this should present the Error.cshtml Shared view (~/Views/Shared/Error.cshtml) which you can customize to expose as much or as little information about the error as you like.

HTH

Ortund
  • 127
  • 7