302重定向相当慢(IIS6)



我有一个网站有一个奇怪的行为:

当点击一个需要验证的页面时,我们会这样处理:

  • http模块检测到需要进行身份验证=>

返回状态401:

context.Response.StatusCode = 401;
// Prevents any other content from being sent to the browser
context.Response.SuppressContent = true;
// Directs the thread to finish, bypassing additional processing
context.ApplicationInstance.CompleteRequest();
  • 检测到重定向到auth表单,并且重定向到适当的登录表单:

重定向代码:

context.Response.Redirect(url, false);
// Directs the thread to finish, bypassing additional processing
context.ApplicationInstance.CompleteRequest();

当带有此代码的站点在IIS7上运行时,不会发现任何问题。但在IIS 6中,登录表单需要2分钟才能加载(在IE、Firefox中,有时它在Chrome中运行良好,但并不总是如此)。

当使用fiddler时,我可以看到标题(302:重定向到最终登录表单)收到得很快,但浏览器等待"ServerDoneResponse"重定向,至少需要2分钟。

起初,没有CompleteRequest(),我认为添加它可以解决问题,但它没有。

有人知道这个问题吗?

提前感谢

编辑:问题发生在Windows 2003 R2 SP2 上托管的网站上

编辑#2:Fiddler提供的信息:

ClientConnected:    14:27:39.219
ClientBeginRequest: 14:27:39.297
GotRequestHeaders:  14:27:39.297
ClientDoneRequest:  14:27:39.297
Determine Gateway:  0ms
DNS Lookup:         0ms
TCP/IP Connect:     0ms
HTTPS Handshake:    0ms
ServerConnected:    14:27:39.250
FiddlerBeginRequest:14:27:39.297
ServerGotRequest:   14:27:39.297
ServerBeginResponse:14:27:39.328
GotResponseHeaders: 14:27:39.328
ServerDoneResponse: 14:29:48.867
ClientBeginResponse:14:29:48.867
ClientDoneResponse: 14:29:48.867
Overall Elapsed:    00:02:09.5694285

通过删除SuppressContent = true,II6不再有问题。

最新更新