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

前端 未结 7 760
你的背包
你的背包 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:30

    If you are using Visual Studio's built in web server (IIS Express), localhost is mapped by default; to enable 127.0.0.1:

    1) At path: %USERPROFILE%\Documents\IISExpress\config

    2) Locate config file: applicationhost.config

    3) - open config file in editor (I use notepad++)

    4) Search for the site port, for example if the url is typically localhost:57578, search "57578" and you should find:

    
    

    5) Change this entry to:

    
    

    6) Save and exit, restart website.

    Note: You will want to repeat this process any time you create a new virtual directory (changing the port number Project/Properties/Web/Project Url), which creates a new entry in the applicationhost.config file.

提交回复
热议问题