How to return on client error message with status code

前端 未结 3 1095
名媛妹妹
名媛妹妹 2021-01-19 04:35

I tried to use this:

return Request.CreateResponse(HttpStatusCode.InternalServerError, \"My message\");

also I tried this one:



        
3条回答
  •  逝去的感伤
    2021-01-19 05:09

    I was able to put a custom message in the error response body with the following code:

    Response.TrySkipIisCustomErrors = true;
    Response.Clear();
    Response.Write( $"Custom Error Message." );
    return new HttpStatusCodeResult( HttpStatusCode.InternalServerError );
    

提交回复
热议问题