OWIN 的 Hello World

使用資料包管理器安裝 Microsoft.Owin.SelfHost

install-packet Microsoft.Owin.SelfHost

從控制檯視窗執行的最低 HelloWorld Web 應用程式的程式碼:

namespace HelloOwin
{
    using System;
    using Owin;

    class Program
    {
        static readonly string baseUrl = "http://localhost:8080";

        static void Main(string[] args)
        {
            using (Microsoft.Owin.Hosting.WebApp.Start<Startup>(baseUrl))
            {
                Console.WriteLine("Prease any key to quit.");
                Console.ReadKey();
            }
        }

        
    }

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.Run(ctx =>
            {
                return ctx.Response.WriteAsync("Hello World");
            });
        }
    }
}