如何在IIS上运行自托管(基于owin的)Web API? [英] How to run self-hosted(owin based) web api on IIS?
问题描述
我已经使用控制台应用程序开发了自托管(基于owin的)Web API.
I have developed self-hosted(owin based) web api using console application.
在开发阶段,我正在运行控制台应用程序,一切正常.
In development phase I was running the console application and everything was okay.
static void Main(string[] args)
{
string baseUri = "http://+:8080";
Console.WriteLine("Starting web Server...");
var server = WebApp.Start<Startup>(baseUri);
Console.WriteLine("Server running at {0} - press Enter to quit. ", baseUri);
Console.ReadLine();
server.Dispose();
}
现在我需要部署自托管的Web api才能在IIS上运行.那么,能否请您告诉我在IIS上启动并运行我的Web api的步骤?
Now I need to deploy my self-hosted web api to run on IIS.So, could you please tell me the steps to get my web api up and running on IIS?
推荐答案
In order to understand theory - take a look at this question. If you want your OWIN self-hosted WEB API application to be running on IIS, you need to use Owin.Host.SystemWeb package. You should:
- 添加一个Startup.cs类(您的IIS托管应用程序的入口点)
- 向OWIN管道介绍您的入口点:用标记启动类owin属性或通过web.config进行操作.(请参阅本文供参考)
P.S.您总是可以在Visual Studio中查看标准的脚手架空Web API项目.它包括现成的IIS Web主机
P.S. You can always take a look at a standard scaffolded empty Web API project in Visual Studio. It includes IIS web host out-of-the-box
这篇关于如何在IIS上运行自托管(基于owin的)Web API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!