【问题标题】:How to make ASP.Net WebAPI Server available on LAN如何使 ASP.Net WebAPI 服务器在 LAN 上可用
【发布时间】:2017-09-10 17:26:17
【问题描述】:

我正在尝试托管 ASP.NET WebAPI 并使其可用于连接到 LAN 上的所有设备。

我可以从我的本地主机访问 API

Getting Proper Response from API

当我尝试从同一 LAN 中的其他计算机访问 API 时,API 进入错误请求 - 无效主机名 HTTP 错误 400

Bad Request - Invalid Hostname

我还为端口号 52022 添加了入站规则

我的绑定配置在

C:\Users***\Documents\IISExpress\config\applicationhost.config

       <sites>
            <site name="WebSite1" id="1" serverAutoStart="true">
                <application path="/">
                    <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:52022:localhost" />
                    <binding protocol="http" bindingInformation="*:52022:" />
                </bindings>
            </site>
            <siteDefaults>
                <logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
                <traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
            </siteDefaults>
            <applicationDefaults applicationPool="Clr4IntegratedAppPool" />
            <virtualDirectoryDefaults allowSubDirConfig="true" />
        </sites>

我仍然无法从连接在同一 LAN 中的另一台计算机访问 API。

【问题讨论】:

    标签: c# asp.net asp.net-web-api2 iis-10


    【解决方案1】:

    为了使 Web 应用程序在 LAN 上可用,您需要在本地主机上部署您的服务。 这里有一些链接

    Deploy web api on localhost

    Deploy asp.net web api on localhost

    【讨论】:

    • 我已经将我的 webapi 项目发布为你提到的文件类型,但我仍然无法访问我的 API
    • 请检查您的网络配置文件
    • web config 文件中应该检查什么样的配置。
    • 请检查连接字符串和权限。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-07
    • 2018-12-18
    • 2012-07-10
    • 2013-03-12
    • 1970-01-01
    • 2017-09-19
    • 2013-03-12
    相关资源
    最近更新 更多