ASP.NET MVC, throw HttpException vs return HttpStatusCodeResult?

后端 未结 4 1052
情书的邮戳
情书的邮戳 2020-12-24 10:47

I am developing a RESTful service and I want to return 400 for all unsupported URLs.

My question is when should I choose method 1 over method 2 and vice-vers

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-24 11:06

    The second seems better as it doesn't involve exception throwing which comes at a micro-cost compared to the first example.

提交回复
热议问题