无法连接到 Windows 商店应用程序中的本地主机 [英] Cannot connect to localhost in windows store application
问题描述
当我在互联网上阅读时,微软阻止了在本地主机 (127.0.0.1) 上为任何端口侦听和接收流量的选项.我希望开发目的是在本地测试我的 2 个服务器/客户端应用程序.我按照这里的说明进行操作:http://msdn.microsoft.com/en-us/library/windows/apps/hh780593.aspx
As i read all over the internet microsoft block the option to listen and recieve traffic on localhost (127.0.0.1) for any port. I want for developing purposus to test my 2 server/client apps locally. I followed the instruction here: http://msdn.microsoft.com/en-us/library/windows/apps/hh780593.aspx
但它不起作用.当我使用调试选项时,我得到:
but it doesnt work. when I use the debug option I am getting:
InternetClient Not Used and Insecure
InternetClientServer Not Used and Insecure
PrivateNetworkClientServer Not Used and Insecure
详细的流量报告
InternetClient Not Used and Insecure
<小时>
InternetClientServer Not Used and Insecure
<小时>
PrivateNetworkClientServer Not Used and Insecure
<小时>
知道为什么它不起作用吗?
any idea why it doesnt work?
推荐答案
我的方案:为内部使用开发了一个 Windows Store 应用程序,在开发机器上运行良好,但是当迁移到另一台机器时,任何 HttpClient 调用都失败了.我在这里遇到了两个问题:
My scenario: Developed an Windows Store App for internal use, ran fine on development machine, however when migrating to another machine any of the HttpClient calls failed. There are two issues I faced here:
与本地机器上的 IIS 通信时 HttpClient 失败
HttpClient failure when communicating to IIS on the local machine
HttpClient 失败,当与本地子网上远程机器上的 IIS 通信时
HttpClient failure When communicating to IIS on a remote machine on the local subnet
问题 2 很容易解决,在 Visual Studio 中将应用设置为允许在功能(Package.appxmanifest > Capabilities)下的私有网络(客户端和服务器)",重新部署,一切正常不错.
Problem 2 was an easy fix, in Visual Studio set the app to allow "Private Networks (Client & Server)" under the capabilities (Package.appxmanifest > Capabilities), redeploy and all is good.
问题 1 很难解决.默认情况下,Visual Studio 在 NetIsolation 中添加一个允许和拒绝本地环回/本地主机访问的异常.您需要在此列表中添加您的应用作为例外,但是 OP 中提供的链接中的信息不起作用,我根本无法使命令起作用,所以我是这样做的:
Problem 1 was difficult to resolve. By default Visual Studio adds an exception in the NetIsolation which permits and denies local loopback/localhost access. You need to add your app as an exception in this list, however the information in the link provided in the OP doesn't work, I couldn't get the command to work at all, so here's how I did it:
(注意确保应用安装在你运行它的机器上)
- 转到您的注册表,然后按 CTRL+F 找到您的应用(例如,如果它名为 TESTApp1,则在搜索框中输入该应用).
- 您应该找到一个注册表项,它看起来像一个 guid 后跟一个名称,例如:
ac2efce7-a15b-40d0-92db-3abde43a6778_1.0.1.15_neutral__025mzc78q1aqe
获得该名称后,在命令提示符(以管理员身份,以防万一)中运行:CheckNetIsolation.exe LoopbackExempt -s
Once you have that name, in a command prompt (as administrator, just in case) run :
CheckNetIsolation.exe LoopbackExempt -s
在输出中,找到您的 GUID.您将在其下方看到 SID,记下此 SID.3) 运行以下命令,在问题机器上输入您的 SID:CheckNetIsolation.exe LoopbackExempt -a -p=SIDHERE
In the output, find your GUID. You will see the SID under it, make a note of this SID.
3) Run the following command, entering in your SID on the problem machine:
CheckNetIsolation.exe LoopbackExempt -a -p=SIDHERE
注意:替代步骤 2:您还可以在以下注册表项下找到您的 SID(假设您已安装该应用):
Note: Alternative step 2: You can also find your SID under the following registry key (assuming you have installed the app):
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Mappings
再次按 CTRL+F 并在那里找到您的应用.
Again, CTRL+F and find your app under there.
这篇关于无法连接到 Windows 商店应用程序中的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!