问题
I want to get started with ASP.NET MVC and WebAPI that was released in Jan 2014.
ASP.NET MVC 5.1, ASP.NET Web API 2.1 and ASP.NET Web Pages 3.1 (Ref: NuGet)
I created a new ASP.NET Web application (.NET 4.5.1) > "Empty template" > "Web API" checked > "No Authentication"
Under the NuGet packages folder I checked the version of libraries referenced by this Web API empty project and found that all DLL (except NewtonSoft) is having a version similar to 5.1..
This is also true for ASP.NET MVC packages.
Question: All libraries are versioned as 5.1..., event ASP.NET MVC is called 5.1 then why is ASP.NET WebAPI called 2.1 - any specific reason or history behind it?
回答1:
Version 2.1 is the version you should pay attention to, since this is the named version of ASP.NET Web API NuGet packages and the only number used officially.
The library version numbers 5.x are internal to the individual component libraries that make up Web API 2.1 - and 5.1 is no coincidence, as you've noticed, since Web API shares a common root with all the other web stuff. So technically, ASP.NET Web API has two different versioning schemes, one being the official version of the product, and one being the library versions.
If you look at the NuGet package for ASP.NET Web API 2.2, you'll see that the URL is
https://www.nuget.org/packages/Microsoft.AspNet.WebApi/5.2.0-rc
This means literally that this is ASP.NET Web API 2.2 version 5.2.0 RC, which is confusing. But one way to think about it is as "ASP.NET Web API 2.2" being the name of the product, whereas 5.2.0 is the internal version number of the product - as with Windows 8 (the name) vs Windows 6.2.9200 (the internal version).
回答2:
The reason is that altough ASP.NET MVC and ASP.NET Web API are often used together in ASP.NET solutions, they are two different frameworks.
ASP.NET Web API is a newer product which was integrated into ASP.NET after MVC
, and thus, the difference in the versioning.
Also not that Razor
which is also a separate framework, is developed/released separately and has its own versioning (3.0.0.0), some other libraries used under ASP.NET has different versions as well.
来源:https://stackoverflow.com/questions/24362315/why-call-asp-net-webapi-package-libraries-with-version-5-1-0-as-asp-net-webapi-2