0

I have a issue in implementing Error handling in Web-APi

[HttpGet]       
public UserAccount Get()
{
    throw new HttpResponseException(
        new HttpResponseMessage(HttpStatusCode.InternalServerError)
    {
        Content = new StringContent("My Error Message"), 
        ReasonPhrase = "Critical Exception"
    });
}

When I tried to call this method from my machine(site is hosted locally), it is working as expected. i.e I got the error message in response (plain text). But when I access the same url from another machine(LAN connected), response is IIS 500 internal error page. Here my problem is that, I am not getting the custom error message "My Error Message"

Any suggestions?

1 Answer 1

1

Add this to your web config:

  <system.webServer>
    <httpErrors errorMode="Detailed"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.