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

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

    In visual studio 2015 with IIS express: first in project properties change project url from http://localhost:(Port No) to : http://127.0.0.1:(Port No)

    and click on Create Visual Directory

    then go to your solution path and open ".vs" dirctory (directory is hidden) and open "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=":8080:localhost" />
                </bindings>
            </site>
            <site name="####" id="2">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="E:\Visual Studio 2015\Projects\####\####" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:5050:localhost" />
                </bindings>
            </site>
            <site name="####(1)" id="3">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="E:\Visual Studio 2015\Projects\####\####" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:5050:127.0.0.1" />
                </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>
    

    and change last binding section of your web app from *:(Port No):localhost to *:(Port No):127.0.0.1

    and stop all running project on IIS Express and restart them.

    0 讨论(0)
提交回复
热议问题