Tuesday, January 13, 2015

Creating an ASP.NET Web API Class Library project

If you read about Project Katana and ASP.NET Web API on the Internet, you may see references on creating an ASP.NET Web API project as a Class Library, but there is very little guidance on how to create a Class Library project in this manner.

Fortunately, it is relatively easy to accomplish:

  1. Create a Class Library project
  2. Add a NuGet Package for Microsoft ASP.NET Web API 2.2 Core Libraries
  3. If you want to get all of the context menu actions that you would normally get in an ASP.NET Web API project, edit the project and add the following Project Type Guids:   <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> 
  4. Unfortunately, because it is a Class Library project, you will have to add the necessary folder structure yourself, but you can copy the required folder structure from an existing ASP.NET Web API project. to replicate it.
That is all there is to it!  Now you will have a Class Library project that can be hosted in a standard ASP.NET Web API  Web Host project.

No comments:

Post a Comment