0

我正在尝试在手持设备(摩托罗拉/Symbol 3090 和 3190)上测试客户端 Windows CE / Compact Framework (.NET 3.5) 应用程序,但是,尽管“假”客户端在桌面上附加并正常工作,但客户端应用程序在桌面无法连接 - 尝试调用 RESTful Web API 方法时出现 400 Not Found 错误。

这是在 Visual Studio 中运行的服务器/Web API 应用程序,由内置/缩小版本的 IIS 托管。

这是可以预料的(不连接)吗?如果没有,问题可能是什么?

更新

注意:在“开始”>“运行”框中输入“cmd”后,我必须混合 Ctrl+Shift+Enter(否则我会得到“请求的操作需要提升(以管理员身份运行)”)。但请注意我在运行第二个命令后得到的手指摇晃(从命令 shell 复制):

netsh http add urlacl url=http://192.76.42.42:80/ user=everyone

已成功添加 URL 预留

netsh firewall add portopening TCP 80 IISExpressWeb enable ALL

因此,既然它“成功执行”了,我很好 - 不必担心重做,对吗?我认为手指摇摆是“我知道你的意思,我为你处理了它,但下次你这样做时,用另一种方式......”类型的消息。

更新 2

显然它是 C:\Users\clay\Documents\IISExpress\config 中的 doch applicationhost.config,而不是项目中的 application.config。

我在那里有这个:

<site name="HandheldServer" id="20">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\HandheldServer\HandheldServer" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:28642:localhost" />
    </bindings>
</site>

并将其更改为此(IP地址已更改):

<site name="HandheldServer" id="20">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/"   
          physicalPath="C:\HandheldServer\HandheldServer"/>
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:80:176.111.222.42" />
    </bindings>
</site>

更新 3

我通过在命令行中输入“iis”并在 IIS 管理器中选择“停止”然后选择“开始”来停止并启动 IIS(我希望/假设重新启动 IIS 与“重新启动 IIS Express”相同) Jeow 在下面),但是当我尝试在手持设备上运行客户端应用程序(从 Visual Studio 2013 开始在桌面上运行服务器 ASP.NET Web API 应用程序)时,我仍然得到“无法连接到远程服务器”。

除了从 VS 之外,我还需要以其他方式启动该应用程序吗?如果是这样,怎么做?从 VS 通过 F5 运行它时,打开的页面位于端口 28642 上。

我的 IIS applicationhost.config 文件现在有这个应用程序:

<bindings>
    <binding protocol="http" bindingInformation="*:80:176.112.111.25" />
    <binding protocol="http" bindingInformation="*:28642:localhost" />
    <binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>

其中第一个绑定是我的桌面 IP 地址,第二个是 VS 运行这个应用程序时使用的端口,第四个是 ssl 版本(还没有使用,至少不是故意的)。

中间的一个是可以在浏览器中看到的(带有 ASP.NET 措辞/占位符文本的“主页”)。

所以我想知道我是否需要从 VS 外部启动这个应用程序和/或需要在 applicationhost.config 中删除这些绑定条目中的一个或多个。

更新 4

傻我!我没有更改客户端中的代码来引用 IP 地址而不是 localhost。所以我改变了这个:

const string uri = "http://localhost:28642/api/inventoryItems";

...对此:

const string uri = "http://192.112.442.13:80/api/inventoryItems";

...在客户端,但它仍然不起作用(尽管它的工作方式不同);我现在得到,“远程服务器返回错误:(404)未找到。

我应该没有“80”,还是......???

  • 并且 applicationhost.config 中的绑定应该是这样的,正确的:

    绑定协议="http" bindingInformation="*:80:192.112.442.13"

?

我尝试删除端口号(80),但仍然收到“404”错误...

更新 5

我终于克服了那个错误,但有两件事不同,所以我不确定是一个,另一个,或者两者兼而有之。

一)我通过在目标设备组合框中选择“Windows CE 设备”直接从 VS 2008 部署。我一直在构建项目,然后通过 Windows Exploder 将 .exe 复制到手持设备。

另一个)我还将代码中使用的 URL 从我的 IP 地址更改为我的机器名称,IOW 来自:

const string uri = "http://192.112.483.97:80/api/platypups";

...到:

const string uri = "http://DBPlatypus/api/platypups";

所以...我现在正在连接到服务器及其 RESTful 方法!

applicationhost.config 中的条目现在是:

<binding protocol="http" bindingInformation="*:PLATYPUS" />
<binding protocol="http" bindingInformation="*:28642:localhost" />

更新 6

现在又回到了 404 Not Found 错误。那是一个短暂的“瞧”!Que sera sera,我想...它似乎与一个新的错误消息有关,即“无法启动 IIS Express Web 服务器”

更新 7

好的,在 applicationhost.config 中,我改变了这个:

<bindings>
  <binding protocol="http" bindingInformation="*:DBPlatypus" />
  <binding protocol="http" bindingInformation="*:28642:localhost" />
  <binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>

到:

<bindings>
  <binding protocol="http" bindingInformation="*:28642:localhost" />
  <binding protocol="http" bindingInformation="*:80:192.112.184.42" />
</bindings>

...我得到了 IIS Express...但是为什么呢?也许确实是名称(而不是 IP 地址)使 IIS Express 感到困惑……不过,我仍然收到 404 Not Found 错误……

const string uri = "http://DBPlatypus:80/api/platypusBills";
const string uri = "http://DBPlatypus/api/platypusBills";
const string uri = "http://192.112.184.42:80/api/platypusBills";
const string uri = "http://192.112.184.42/api/platypusBills";
4

1 回答 1

2

您需要配置 IIS Express 以在您的 IP 地址上为您的应用程序提供服务。默认情况下,它只响应您的移动模拟器/设备看不到的 localhost。

查看http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx中的 1.Getting IIS Express to service external over Port 80 部分

引用自网站

Run the following in command line
netsh http add urlacl url=http://hanselman-w500:80/ user=everyone
netsh firewall add portopening TCP 80 IISExpressWeb enable ALL


Add to applicationHost.config
<binding protocol="http" bindingInformation="*:80:hanselman-w500" />

然后重新启动 IIS Express。

编辑:

在命令行中运行 ipconfig 以获取您当前的 IP 地址,并将 hanselman-w500 替换为该 IP 地址。

于 2013-11-06T01:06:19.343 回答