What is the difference between HttpResponseMessage and HttpResponseException

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

I tried to understand both and write sample code:

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


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 11:46

    HttpResponseException is useful when your Controller Action signature looks like

      Foo Get(int id)
    

    In this case, you cannot easily return status code like 400.

    Be aware that HttpResponseMessage is going away in the next release of Web API.

提交回复
热议问题