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
"System.Web.Http" is used for creating WebAPIs.
"System.Net.Http" is used for consuming WebAPIs (using HttpClient
class)
System.Web heavily depends on IIS web server, which can only be hosted on a Windows machine. As Microsoft is heading to open source and is starting to support multiple platforms like Linux and Mac, they need to extract their functionality which will be independent of IIS server. As a result, System.Net is independent of IIS features and is deployable to different platforms.
System.Net.Http is for client-side HTTP programming. System.Web.Http is for server-side HTTP programming.
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.
System.Net.Http relates to network programming while System.Web.Http relates specifically to programming for the web.