Asp.net HTTP请求未经客户端身份验证方案';Ntlm';。从服务器接收的身份验证标头为';NTLM&x27;

Asp.net HTTP请求未经客户端身份验证方案';Ntlm';。从服务器接收的身份验证标头为';NTLM&x27;,asp.net,wcf,iis-7,ntlm,Asp.net,Wcf,Iis 7,Ntlm,这让我快发疯了。 我正在尝试通过ASP.NET web表单访问WCF服务, 我正在设置通道工厂的绑定,如下所示: BasicHttpBinding b=null; if(Communication.SlServiceURL.StartsWith(“https”)) b=新的BasicHttpBinding(BasicHttpSecurityMode.Transport); 其他的 { b=新的BasicHttpBinding(); b、 Security.Mode=BasicHttpSecuri

这让我快发疯了。 我正在尝试通过ASP.NET web表单访问WCF服务, 我正在设置
通道工厂的绑定,如下所示:

BasicHttpBinding b=null;
if(Communication.SlServiceURL.StartsWith(“https”))
b=新的BasicHttpBinding(BasicHttpSecurityMode.Transport);
其他的
{
b=新的BasicHttpBinding();
b、 Security.Mode=BasicHttpSecurityMode.TransportCredentialOnly;
}
b、 MaxBufferSize=2147483647;
b、 MaxReceivedMessageSize=2147483647;
b、 Security.Transport=new-HttpTransportSecurity{ClientCredentialType=HttpClientCredentialType.Ntlm,ProxyCredentialType=HttpProxyCredentialType.None};
b、 Security.Message=new BasicHttpMessageSecurity{ClientCredentialType=BasicHttpMessageCredentialType.UserName};
然后,我通过以下方式创建一个新的通道包装器:

公共ClientChannelWrapper(绑定绑定,EndpointAddress remoteAddress) { m_工厂=新的ChannelFactory(绑定,远程地址); }
我正在将绑定和URL作为
remoteAddress
传递

问题是:当我使用IIS 7调用生产服务器中的服务时,在站点上启用了Windows身份验证,并且只有“NTLM”作为身份验证的提供程序,其他一切都被禁用(没有匿名、表单等) 我得到一个例外:

异常类型:MessageSecurityException

异常消息:HTTP请求未经客户端身份验证方案“Ntlm”授权。从服务器接收的身份验证标头为“NTLM”

这很奇怪,我似乎找不到解决的办法。我还有一个Silverlight应用程序托管在另一个ASP.NET表单中,它可以很好地与此绑定一起工作,这让我很吃惊,因为为什么在同一个IIS站点中托管的ASP.NET站点中不可以使用相同的东西呢

同样奇怪的是:当使用F5从Visual Studio启动站点时,它在访问IIS7机器中的生产WCF服务时工作。一旦我部署了站点,我就会得到异常

编辑:现在很清楚为什么Silverlight的行为不同于ASP.NET,因为Silverlight直接通过客户端计算机与服务进行通信。还是没有运气,只有一个例外