How to run self-hosted(owin based) web api on IIS?

一笑奈何 提交于 2021-02-19 06:50:34

问题


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();
    }

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?


回答1:


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:

  • Add a Startup.cs class (entry point for your IIS-hosted app)
  • Tell OWIN pipeline about your entrypoint: Mark Startup class with owin attribute OR do it via web.config. (See this article for reference)

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



来源:https://stackoverflow.com/questions/48201847/how-to-run-self-hostedowin-based-web-api-on-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!