.net Windows应用商店应用程序407代理连接到asmx服务时出错

.net Windows应用商店应用程序407代理连接到asmx服务时出错,.net,authentication,proxy,windows-store-apps,asmx,.net,Authentication,Proxy,Windows Store Apps,Asmx,我的windows应用商店应用程序在连接到我的asmx web服务时收到407错误。我可以通过url fine浏览到webservice,并在IE中调用它。当从单独的项目(托管在同一iis上的signalr hub)调用webservice时,webservice可以工作 远程服务器返回了意外响应:(407)代理 需要认证(Forefront TMG需要授权 完成请求。对Web代理筛选器的访问被拒绝。) web服务引用是在visual studio中通过单击引用并添加服务引用创建的,我正在使用

我的windows应用商店应用程序在连接到我的asmx web服务时收到407错误。我可以通过url fine浏览到webservice,并在IE中调用它。当从单独的项目(托管在同一iis上的signalr hub)调用webservice时,webservice可以工作

远程服务器返回了意外响应:(407)代理 需要认证(Forefront TMG需要授权 完成请求。对Web代理筛选器的访问被拒绝。)

  • web服务引用是在visual studio中通过单击引用并添加服务引用创建的,我正在使用“serviceReference.SoapClient”连接方式。当不在代理后面时,此选项有效
  • 我正在visual studio内置的windows 8模拟器中运行windows服务。这是在IIS中运行web服务的同一台计算机上
  • 我已在应用程序清单设置中启用“企业身份验证”
  • 我已将以下内容添加到.asmx web.config中

    <system.net>
        <defaultProxy enabled="true" useDefaultCredentials="true" />
    </system.net>
    
  • 我只是在一个新的网络上尝试安装应用程序时才开始遇到这个问题。它在家里工作正常-“在我的电脑上工作”;)
我通过以下链接声明绑定解决了这个难题:

我还根据打开了“专用网络(客户端和服务器)”

我的语法示例可帮助其他有此问题的人:

    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
    System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri("http://localhost/WebService/myFileName.asmx"));
    MyService.MyServiceSoapClient client = new MyService.MyServiceSoapClient(binding, address);
    MyService.MyMethodResponse response = await client.MyMethodAsync(null);
    var result = response.Body.MyMethodResult;
    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
    System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri("http://localhost/WebService/myFileName.asmx"));
    MyService.MyServiceSoapClient client = new MyService.MyServiceSoapClient(binding, address);
    MyService.MyMethodResponse response = await client.MyMethodAsync(null);
    var result = response.Body.MyMethodResult;