在VS调试站点,默认使用IISExpress,locall+端口,为了使用IP地址、多域名调试,找到
IISExpress下的applicationhost.config,在目标站点下增加类似行:
<binding protocol="http" bindingInformation="*:51000:192.168.1.10" />
变成
<binding protocol="http" bindingInformation="*:51000:localhost" />
<binding protocol="http" bindingInformation="*:51000:192.168.1.10" />
通过IP地址访问时可能出现400错误,管理员权限打开CMD,输入:
netsh http add urlacl url=http://192.168.1.10:51000/ user=everyone
本来好好的,结果手贱,又输入一个:
netsh http add urlacl url=http://127.0.0.1:51000/ user=everyone
由于一直用192那个调试,没发现问题,后来发现VS不能调试了,提示无法连接配置服务器,打开其它项目却能调试,怀疑到端口占用,然后寻到上述命令,输入下面两句,均报错误:
netsh http delete urlacl url=http://127.0.0.1:51000/ user=everyone
和
netsh http delete urlacl url=http://127.0.0.1:51000
上网搜,都没有找到相应方法,突然尝试打入:
netsh http delete urlacl url=http://127.0.0.1:51000/
顺利执行,打开VS调试,回复正常,唉,原来少打了个“/”