Start by creating an empty Web project, as shown in:
After the project is successfully created, install the following three package.
Install-package Microsoft.aspnet.webapi-version 5.2.2
Install-package Microsoft.aspnet.webapi.owin-version 5.2.2
Install-package Microsoft.owin.host.systemweb-version 3.0.0
Create Owin Startup class
1 usingSystem;2 usingSystem.Threading.Tasks;3 usingMicrosoft.owin;4 usingOwin;5 usingSystem.Web.Http;6 7[Assembly:owinstartup (typeof(Firstowinwebapi.startup))]8 9 namespaceFirstowinwebapiTen { One Public classStartup A { - Public voidConfiguration (Iappbuilder app) - { thehttpconfiguration config =Newhttpconfiguration (); - - //Web API Routes - CONFIG. Maphttpattributeroutes (); + - //webapiconfig.register (config); + A app. Usewebapi (config); at } - } -}
Create an API Controller.
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Net;5 usingSystem.Net.Http;6 usingSystem.Web.Http;7 8 namespacefirstowinwebapi.controllers9 {Ten[Routeprefix ("Api/helloworld")] One Public classHelloworldcontroller:apicontroller A { -[Route ("")] - Publicihttpactionresult Post () the { - - returnok<string> ("Hello World"); - + } - + } A}
F5 run, Access API using Postman
Some other Owin middleware packages:
Install-package Microsoft.aspnet.webapi-version 5.2.2
Install-package Microsoft.aspnet.webapi.owin-version 5.2.2
Install-package Microsoft.owin.host.systemweb-version 3.0.0
Install-package Microsoft.owin.cors-version 3.0.0
Install-package Microsoft.owin.security.oauth-version 3.0.0
Install-package Microsoft.owin.security.jwt-version 3.0.0
Install-package system.identitymodel.tokens.jwt-version 4.0.0
Install-package Thinktecture.IdentityModel.Core Version 1.2.0
Install-package Microsoft.aspnet.identity.owin-version 2.0.1
Install-package Microsoft.aspnet.identity.entityframework-version 2.0.1
Create a WEBAPI project that uses Owin to host based on an empty project template