0

so client accesses the server, but if an error occurs im trying to return the error message 'No Client access exists's'...was using the httpStatusCodeResult but it just returns 'The remote server returned an error: (404) Not Found.' I need the actual error msg aswell.

any ideas?

public ActionResult GetPLUAndDeptInfo(string authCode)
        {
            try
            {
                ClientAccount client = GetClientAccount(authCode);

                if (client == null)
                {
                    return new HttpStatusCodeResult(404, "Error in cloud - GetPLUAndDeptInfo - No Client Account exists");
                }
John
  • 3,965
  • 21
  • 77
  • 163
  • Looking at your code that should work. Your custom error will render as Status Text. Not sure if there is something else in your code causing your custom 404 to not display. – Brandon O'Dell Feb 16 '14 at 21:40

1 Answers1

0

By returning the HttpStatusCodeResult you will most likely be seeing either a browser or an IIS generated error page, which will be ignoring the extra message details you are passing back.

For what you are trying to achieve you need to implement some form of custom error handling so you can display the error message to the user.

Instead try throwing a HttpException, and managing the redirect to a 404 handler using config or Application_Error.

Here are a couple of solutions:

Community
  • 1
  • 1
Brent Mannering
  • 2,316
  • 20
  • 19