I am trying to to run a self hosted web api app using owin like here
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
public class Program
{
static void Main()
{
string baseAddress = "http://localhost:9000/";
// Start OWIN host
using (WebApp.Start<Startup>(url: baseAddress))
{
Console.WriteLine("App started");
Console.ReadLine();
}
}
}
public class Startup
{
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
public void Configuration(IAppBuilder appBuilder)
{
// Configure Web API for self-host.
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
appBuilder.UseWebApi(config);
}
}
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
which event.
I tried to install Microsoft.AspNet.WebApi (Web Api 2.1) via nuget which fails because of framework 4.5 requirement so I installed AspNetWebApi (Web Api).
But I can't find the extension method UseWebApi anywhere. Do I have to install another package or is it impossible to host a web api with Framework 4?
System.Web.Http.dll v4.0- Jürgen SteinblockHttpSelfHostServer (Microsoft.AspNet.WebApi.SelfHost package)but I am searching for an Owin implementation because I already host Nancyfx with owin. - Jürgen Steinblock