Skip to content

标题: UWP默认不允许访问127.0.0.1

创建: 2023-08-31 15:21 更新: 2023-08-31 15:59 链接: https://scz.617.cn/windows/202308311521.txt

参看

Using network loopback in side-loaded Windows Store apps - [2016-06-22] https://learn.microsoft.com/en-us/previous-versions/windows/apps/dn640582(v=win.10)

从Win8开始,UWP默认不允许访问127.0.0.1;Edge算UWP,可用它实测之;这幺蛾子 我才知道。不过Win10好像已默认将Edge加入白名单,使得Edge可访问回环地址。系 统有个自带工具CheckNetIsolation.exe,可以管理这种白名单。


$ CheckNetIsolation /?

Usage: CheckNetIsolation [Module] List Of Modules: LoopbackExempt - controls the loopback exemption of AppContainers and Package Families to ease application development. Debug - Starts a network traffic troubleshooting session of an AppContainer or Package Family. Generates a report of network capabilities that are used, not used or missing, together with the network traffic generated by the application. -? - Displays this help message.


$ CheckNetIsolation LoopbackExempt /?

Usage: CheckNetIsolation LoopbackExempt [operation] [-n=] [-p=] List of operations: -a - Add the AppContainer or Package Family to the loopback exempted list. -d - Delete an AppContainer or Package Family from the loopback exempted list. -c - Clear the list of loopback exempted AppContainers and Package Families. -s - Show a list of loopback exempted AppContainers and Package Families.

  List of arguments:
      -n= - AppContainer Name or Package Family Name.
      -p= - AppContainer or Package Family Security Identifier (SID).
      -?  - Displays this help message for the LoopbackExempt module.

查看白名单:

CheckNetIsolation LoopbackExempt -s

我的Win10白名单中已有Edge。假设有用Edge访问回环地址的需求,又不在白名单中, 可手工添加:

CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe

如何知道"-n="的值呢?至少可用PowerShell:

Get-AppxPackage | Where-Object {$_.Name -like 'Edge'} | Select PackageFamilyName

现在我知道下面这个设置在干啥了,就是加回环地址白名单:

Fiddler->Tools->Win8 Loopback Exemptions