处理Windows身份验证登录弹出窗口取消单击 [英] Handle windows authentication login popups Cancel click

查看:117
本文介绍了处理Windows身份验证登录弹出窗口取消单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为App的简单Web应用程序,该应用程序受Windows身份验证保护.我在web.config中将身份模拟设置为true. App目录中只有一页(Default.aspx).当用户进入站点时,例如: http://localhost/App ,将弹出登录窗口.当用户单击取消"时,IIS重定向到页面,错误401.2.我想重定向到 http://localhost/App/app_start/login.aspx . App_start是通过表单身份验证"保护的应用程序.我试图通过在Global.asax文件中添加Application_EndRequest方法来以编程方式处理重定向.但是,当用户单击取消"时,不会触发Application_EndRequest.用户成功登录后,将触发该方法.有什么方法可以通过编程方式或以其他方式来处理错误401.2?

I have simple web application called App that is secured with Windows Authentication. I have set identity impersonate to true in web.config. There is only one page (Default.aspx) in App directory. When user enters the site ex.: http://localhost/App the login window pops up. When user clicks Cancel, IIS redirects to page with an error 401.2. I want to redirect to http://localhost/App/app_start/login.aspx. App_start is an aplication that is secured with Forms Authentication. I tried to handle programmatically the redirection by adding Application_EndRequest method in Global.asax file. But when user clicks Cancel the Application_EndRequest is not being fired. When user successfully logs in the method is being fired. Is there any way to handle error 401.2 programmatically or maybe in a different way?

Application_EndRequest代码:

Application_EndRequest code:

如果(Response.StatusCode == 401)

if (Response.StatusCode == 401)

{

 Response.Clear();

 Response.Write("You don't have access to content.");

}

App应用程序的web.config文件:

The web.config file of App application:

感谢您的帮助.

此致

彼得.

推荐答案

您应该能够将IIS中的401.2错误设置为重定向到URL而不是文件.如果执行此操作,只需将401.2重定向设置为另一个Web应用程序即可,这应该可以工作.

You should be able to set the 401.2 error in IIS to be redirected to a URL instead of a file. If you do this just set the 401.2 redirect to your other web application and that should work.

右键单击iis,属性,自定义错误中的网站.

Right Click on the site in iis, properties, custom errors.

这篇关于处理Windows身份验证登录弹出窗口取消单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆