Visual studio Debug调试webservice 使用ip代替localhostt配置IIS Express

话说好久没写博客了。

遇到的问题:

要调试一个安卓程序,该程序需要与webservice通信,手机和电脑在同一个局域网,电脑上用visual studio Debug运行一个webservice,该服务是用IIS Express运行起来的,但是运行起来后地址栏的地址是http://localhost:44366/xxx.asmx,电脑的ip是192.168.0.6,用手机浏览器访问http://192.168.0.6:44366/xxx.asmx,却提示HTTP 400 错误,The request hostname is invalid. 导致无法调试这个安卓程序。

解决办法:

打开IIS Express的配置文件 C:\Users\Administrator\Documents\IISExpress\config\applicationhost.config,找到 site 节点,修改为:

xml 复制代码
<site name="WebSite1" id="1" serverAutoStart="true">
        <application path="/">
            <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation="*:44366:192.168.0.6" />
        </bindings>
  </site>

打开visual studio解决方案目录下的.vs目录,找到项目的applicationhost.config文件,例如:C:\MyStudy\Homework\WebServiceDemo\.vs\WebServiceSln\config\applicationhost.config 其中WebServicecSln就是你的解决方案的名称,找到 site 节点,修改为:

xml 复制代码
<site name="WebServicecOne" id="2">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\MyStudy\Homework\XiBang\xi-bang-tec-pdaapi\PDAAPICrack" />
        </application>
        <bindings>
            <binding protocol="https" bindingInformation="*:44366:192.168.0.6" />
            <binding protocol="http" bindingInformation="*:44366:192.168.0.6" />
        </bindings>
 </site>

以上 WebServiceOne 是项目名称,修改完毕后,Debug调试,手机浏览器就能访问 http://192.18.0.6:44366/xxx.asmx 了。

记录一下:华为 mate60 用原厂数据线,在开发者选项开启debug调试后,连接电脑选择文件传输,但 android studio 中不显示手机设备也搜索不到手机设备,后来下载安装了华为的 HiSuite 后,再插上数据线手机上就弹出了一个"允许 USB 调试"的弹框,选择确认后,android studio 上就自动出现了当前的手机设备。

相关推荐
手机不死我是天子1 天前
《Android 核心组件深度系列 · 第 3 篇 BroadcastReceiver》
android·android studio
fundroid2 天前
Android Studio 新功能 Journey Test:借助 AI 实现基于自然语言的 UI 测试用例编写
android studio
Yupureki2 天前
从零开始的C++学习生活 5:内存管理和模板初阶
c语言·c++·学习·visual studio
旷野说3 天前
Android Studio Narwhal 3 特性
android·ide·android studio
Yupureki4 天前
从零开始的C++学习生活 3:类和对象(中)
c语言·c++·学习·visual studio
安卓AndroidQ4 天前
Android Studio 代码混淆核心解释
android·ide·android studio
qq_7391753694 天前
Android Studio 实现四则运算+开方+倒数简易计算器
android·python·android studio
就叫飞六吧4 天前
Android studio -kt构建一个app
android·ide·android studio
玖笙&4 天前
✨WPF编程基础【2.1】布局原则
c++·wpf·visual studio
玖笙&4 天前
✨WPF编程基础【2.2】:布局面板实战
c++·wpf·visual studio