What is the difference between HttpResponseMessage and HttpResponseException

后端 未结 5 1168
天涯浪人
天涯浪人 2020-12-07 11:06

I tried to understand both and write sample code:

 public HttpResponseMessage Get()
 {
     var response = ControllerContext.Request
                                 


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 12:01

    HttpResponseException derives from Exception and embeds HttpResponseMessage. Since it derives from Exception it can be useful in try-catch scenarios.

    Default status code returned by HttpResponseException is HttpStatusCode.InternalServerError.

提交回复
热议问题