简体   繁体   中英

Unable to access ASP.NET API from other computers on local network

I have an API written in ASP.NET and when I run it with IIS express, it opens up to the following page https://localhost:44381/api/strs . This works completely fine. However, when I try to access it from another computer or even my local computer using my LAN address, https://10.0.0.185:44381/api/strs , I get the error message HTTP Error 400. The request hostname is invalid.

EDIT - I realized I forgot to add that accessing from http://10.0.0.185:19093/ also gives the same error

These are my bindings

                <bindings>
                    <binding protocol="https" bindingInformation="*:44381:10.0.0.185" />
                </bindings>

and here is my launchsettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:19093",
      "sslPort": 44381
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "api/strs",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "TestApi2": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "api/strs",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    }
  }
}

I have been trying to solve this problem for hours but no matter what I do I just get status code 400 or "network connection reset". Any help is appreciated.

Use this link to configure and deploy an application with IIS on windows,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM