处理 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?
Application_EndRequest代码:
if (Response.StatusCode == 401)
{
Response.Clear();
Response.Write("You don't have access to content.");
}
App应用程序的web.config文件:
感谢您的帮助。
此致,
彼得。
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 code:
if (Response.StatusCode == 401)
{
Response.Clear();
Response.Write("You don't have access to content.");
}
The web.config file of App application:
Thanks for help.
Sincerely,
Peter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够将 IIS 中的 401.2 错误设置为重定向到 URL 而不是文件。如果您这样做,只需将 401.2 重定向设置为您的其他 Web 应用程序,就可以了。
右键单击iis中的站点,属性,自定义错误。
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.
Right Click on the site in iis, properties, custom errors.