且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Self hosted OWIN 绑定地址127.0.0.1,外网无法访问

更新时间:2022-09-20 19:28:01

static void Main()
        {
            string baseAddress = "http://localhost:4004/";
            /*Render application
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrontVorm());
            */
            // Start OWIN host 
            StartOptions options = new StartOptions();
            options.Urls.Add("http://localhost:4004");
            options.Urls.Add("http://127.0.0.1:4004");
            options.Urls.Add(string.Format("http://{0}:4004", Environment.MachineName));
            using (WebApp.Start<Program>(options))
            {
                // Create HttpCient and make a request to api/values 
                HttpClient client = new HttpClient();
            }
}

 

如上绑定,外网服务访问(防火墙端口已经配置开放) 

 

解决:

options.Urls.Add("http://+:4004");


本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/p/7944106.html,如需转载请自行联系原作者