对aspx页面的双重请求,NTLM身份验证请求失败

时间:2012-03-27 15:15:05

标签: asp.net iis iis-7 ntlm

我有以下配置:

  • IIS 7.5
  • 网站A - 身份验证:禁用所有选项,仅禁用Windows 验证启用。
  • 应用程序B(作为A的子Web应用程序):身份验证:启用匿名,启用基本,禁用Windows身份验证。

两个运行ASP.NET 4的应用程序,独立的应用程序池,经典模式。

现在,应用程序B在Fiddler中注意到这种奇怪的行为。 对于aspx页面的每个请求,它显示两个条目: 第一个请求:

GET https://example.com/page.aspx HTTP/1.1
Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: https://example.com/
Accept-Language: en-GB
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Zune 4.7)
Cookie: ASP.NET_SessionId=123456789
Accept-Encoding: gzip, deflate
Host: example.com
Authorization: NTLM DFGHJKLDRFGHNXAAAAA==
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 0

作为回复,我得到401.然后,第二个请求是针对相同的资源:

GET https://example.com/page.aspx HTTP/1.1
Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: https://example.com/
Accept-Language: en-GB
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Zune 4.7)
Authorization: Basic ZXVyasdasdasdasdasdasd=
Accept-Encoding: gzip, deflate
Host: example.com
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 0
Cookie: ASP.NET_SessionId=lasdasdasdasdasdasdasd

第二个没有状态200。

区别在于“授权”行,第一个显示NTLM(拒绝401访问)有时会导致javascripts的意外行为,例如:使用更新面板(Sys.WebForms.PageRequestManagerParserErrorException)。

我错过了什么?如何设置IIS(或webapp)不要发出第一个“NTLM”请求? 谢谢你的帮助。

编辑:我注意到的另一个有趣的问题:在同一个环境中,我有第二组这些应用程序(只是绑定到另一个数据库)。在此集中,应用程序A启用了匿名身份验证,启用了表单,并禁用了Windows。应用B具有与第一组相同的设置。在这种情况下,没有失败的请求(401)。一切顺利。

1 个答案:

答案 0 :(得分:1)

看起来问题已经解决了。由于该站点已在IE中添加为Intranet站点,并且已启用Intranet区域的自动登录,因此企业域计算机首先尝试了NTLM身份验证。这就是NTLM请求的来源 - 并且由于IIS中禁用了Windows auth,因此它提供了错误的响应。