Iis Can';t通道http://localhost 侧装后

Iis Can';t通道http://localhost 侧装后,iis,win-universal-app,Iis,Win Universal App,我的应用程序UWP正在通过IIS访问一些数据 public static async Task<List<Uri>> GetMedia() { List<Uri> target = new List<Uri>(); HtmlDocument document = new HtmlDocument(); var httpClient = new HttpClie

我的应用程序UWP正在通过IIS访问一些数据

 public static async Task<List<Uri>> GetMedia()
        {
            List<Uri> target = new List<Uri>();
            HtmlDocument document = new HtmlDocument();
            var httpClient = new HttpClient();
            var urlVideos = "http://localhost/Videos";
            var response = await httpClient.GetAsync(urlVideos);
            var result = await response.Content.ReadAsStringAsync();
            string htmlString = result;

            document.LoadHtml(htmlString);
            var collection = document.DocumentNode.DescendantsAndSelf()  ;
            foreach (HtmlNode link in collection)
            {
                if (link.Attributes.Contains("href") && !string.IsNullOrEmpty(link.Attributes["href"].Value.Trim().Trim('/')))
                {
                    target.Add(new Uri("http://localhost" + link.Attributes["href"].Value));
                }
            }
            return target;
        }
公共静态异步任务GetMedia() { 列表目标=新列表(); HtmlDocument document=新的HtmlDocument(); var httpClient=新的httpClient(); var url视频=”http://localhost/Videos"; var response=wait-httpClient.GetAsync(urlvides); var result=await response.Content.ReadAsStringAsync(); 字符串htmlString=结果; document.LoadHtml(htmlString); var collection=document.DocumentNode.DegenantsAndSelf(); foreach(集合中的HtmlNode链接) { if(link.Attributes.Contains(“href”)&&!string.IsNullOrEmpty(link.Attributes[“href”].Value.Trim().Trim('/')) { 添加(新Uri(“http://localhost“+link.Attributes[”href“].Value)); } } 回报目标; } 那么我就这样调用这个方法,

私人IList_视频 _videos=wait Proxy.GetMedia()


它运行得很好,除了在我侧面加载应用程序之后,我才意识到_video仍然是空的,我可以浏览,所以我假设IIS配置良好,

如果你想从侧面加载的应用程序访问localhost,你必须为这个特定的应用程序启用网络环回。每个应用程序都禁止默认访问。 您可以在命令行上运行此命令:

checknetisolation LoopbackExempt -a -n=YourAppContainerPackageFamilyName
用应用程序的AppContainer名称替换AppContainerPackageFamilyName。您可以在应用程序的*.appxmanifest中找到它。您必须在加载应用程序的计算机上运行此操作。在dev机器上,它是根据默认值启用的。 另请参见此链接:

嗨,达米尔,谢谢,但我在运行此命令时出错了错误1337-538好的,我稍微修改了这个答案。如果从应用程序获取Packagefamilyname,则参数为-n而不是-p。我可以重新解释你的问题。如果您将上面的命令与-n一起使用,它将工作。太好了,很高兴听到这个消息!非常感谢。为我们节省了不少时间和挫折。