How do we determine whether we are using Web API 1 or Web API 2?

asp.netVersionasp.net Web-Api

asp.net Problem Overview


Introduce the problem

I would like to know whether we are using Web API 1 or 2. My own packages.config indicates version 5.0.0. Is that Web API 1 or 2?

Search, and research

I have tried Googling the following:

>"web api 1" "web api 2"

and

>ASP.NET Web API release history

and

>ASP.NET Web API nuget

The best references seem to be these two nuget pages:

Is that right? How would I know for sure?

asp.net Solutions


Solution 1 - asp.net

I think what you found seems correct. I had the same question then I had a look under my installed packages when you go "Manage Nuget packages". There was an item installed with the name "Microsoft ASP.NET WEB API 2.2". So I was able to determine my own version from there.

Solution 2 - asp.net

I'm not sure what @John meant with the package name above. I'm having the following package right now:

Microsoft.AspNet.WebApi.5.2.3

Based on this article http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-22 I assume that starting from the package version 5.2.2 it's Web API 2.2 version.

Solution 3 - asp.net

I always try this instead -

In the controller make a method

public IHttpActionResult MyResult(){
    return Ok();
}

If you get compilation error then it is API 1.0.

If no compilation error then you are referencing API 2.0.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShaun LuttinView Question on Stackoverflow
Solution 1 - asp.netJohnView Answer on Stackoverflow
Solution 2 - asp.netSerjGView Answer on Stackoverflow
Solution 3 - asp.netNewton SheikhView Answer on Stackoverflow