Why is there both a System.Net.Http and System.Web.Http namespace?

后端 未结 5 1400
渐次进展
渐次进展 2021-01-31 01:34

Just a simple question as I\'m studying the various class libraries available in .NET. I noticed that there\'s a System.Net.Http namespace and a System.Web.H

5条回答
  •  野的像风
    2021-01-31 02:22

    From my experience, the separation between the two namespaces becomes clear when you look at the difference between self hosted webapi services vs IIS-hosted. Self hosted only requires System.Http, whilst IIS hosted needs both. See Difference between "MapHttpRoute" and "MapRoute"? for a similar discussion and useful links.

    So, the reason there are two is so that you can create a self-hosted web service that doesn't depend on the entire ASP.NET stack.

    Neither of them are deprecated.

    I haven't seen an official Microsoft explanation for this, but that's the best I've been able to find.

提交回复
热议问题