OWin

1.新建控制台程序

2.添加一个类

OWin

 public class Startup1

    {

        public void Configuration(IAppBuilder appBuilder)

        {

            appBuilder.Run(HandleRequest);

        }

        static Task HandleRequest(IOwinContext context)

        {

            context.Response.ContentType = "text/plain";

            return context.Response.WriteAsync("Hello, world!");

        }

    }
class Program

    {

        static void Main(string[] args)

        {



            var url = "http://localhost:8080/";

            var startOpts = new StartOptions(url) { };



            using (WebApp.Start<Startup1>(startOpts))

            {

                Console.WriteLine("Server run at " + url + " , press Enter to exit.");

                Console.ReadLine();

            }

            //需要安装Microsoft.AspNet.WebApi.OwinselfHost

        }

    }

先运行控制台,然后在浏览器上输入网址即可

你可能感兴趣的:(in)