Web API自托管

编程入门 行业动态 更新时间:2024-10-22 20:36:04
本文介绍了Web API自托管-在所有网络接口上绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使Web API自托管主机在所有网络接口上绑定?

How do you make a Web API self host bind on all network interfaces?

我目前有以下代码.不幸的是,它仅在本地主机上绑定.因此,无法从本地主机访问该服务器.

I have the below code currently. Unfortunately, it binds only on localhost. So access to this server from other than localhost is failing.

var baseAddress = string.Format("localhost:9000/"); using (WebApp.Start<Startup> (baseAddress)) { Console.WriteLine("Server started"); Thread.Sleep(1000000); }

推荐答案

只需像这样更改基址

var baseAddress = "*:9000/"; using (WebApp.Start<Startup> (baseAddress)) { Console.WriteLine("Server started"); Thread.Sleep(1000000); }

它应该正确地绑定到所有接口.

And it should bind correctlly to all interfaces.

更多推荐

Web API自托管

本文发布于:2023-11-15 04:17:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591072.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Web   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!