1.打开项目属性,web服务器是默认的IIS Express.

【VS调试】VS调试的时候使用IP地址,局域网的设备可以访问并调试

 

2.找到项目站点的配置文件 applicationhost.config,一般默认的位置在: C:\Users\userName\Documents\IISExpress\config

我的是在 D:\Documents\IISExpress\config

也可以如下方法找到:

启动web调试后,电脑右下角有个IIS Express图标,点击显示所有应用程序

【VS调试】VS调试的时候使用IP地址,局域网的设备可以访问并调试

就可以看到配置的所在位置。

【VS调试】VS调试的时候使用IP地址,局域网的设备可以访问并调试

 

3.打开applicationhost.config文件,找到项目所在的节点,我的项目名称是MyApp。

添加一行:<binding protocol="http" bindingInformation="*:11946:192.168.137.210" />   ,设置自定义的IP和端口。

            <site name="MyApp" id="4">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="D:\CSharpWorkSpace\MyApp\MyApp" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:11946:localhost" />
                    <binding protocol="http" bindingInformation="*:11946:192.168.137.210" />
                </bindings>
            </site>

 

问题:怎么使用域名访问呢?

相关文章: