C# Web - localhost:port works, 127.0.0.1:port doesn't work

前端 未结 7 918
你的背包
你的背包 2021-02-01 01:48

I just finished adding C# Web API components (Web API Models & Controllers) to a localhost copy of an existing project.

This Web API\'s GET-methods shou

7条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 02:16

    This worked form me On visual Studio >= 2017, for dotnet core projects:

    1- Edit applicationhost.config located inside .vs\config in your project and add bindings for 127.0.0.1 for http and https:

    
        ...
         
            ...
            
              
                
                
                
            
        
          ...
    
    

    2- edit iisexpress launch settings in vs: from solution explorer under the api project tree

    [your project] > properties > launchSettings.json:

    "iisSettings": {
        ...
        "iisExpress": {
         **"applicationUrl": "https://127.0.0.1:44380",// make sure to use https**
          "sslPort": 44380
        }
      },
    

    make sure to use https in "applicationUrl": "https://127.0.0.1:44380"

    • you can replace the ports as you like

提交回复
热议问题