using Microsoft.Owin;
using Microsoft.Owin.Hosting;
using System;
namespaceOWINDemo
{classProgram
{staticvoid Main(string[] args)
{
var baseAddress = "http://localhost:9001";
WebApp.Start<Startup>(url: baseAddress);
Console.WriteLine("exit by any key");
Console.ReadLine();
}
}
}
Startup.cs
using Owin;
using System.Web.Http;
namespace OWINDemo
{
publicclass Startup
{
publicvoidConfiguration(IAppBuilder appBuilder)
{
var config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name:"DefaultApi",
routeTemplate:"api/{controller}/{id}",
defaults:new {id=RouteParameter.Optional}
);
appBuilder.UseWebApi(config);
appBuilder.Use<SampleMiddleware>("[自定义可选的object参数]");
}
}
}