如何检查内容页面中是否单击了 MasterPage 注销按钮
我有一个要求,我需要检查用户是否单击母版页中的注销按钮并跳过内容页中的方法。因为该方法具有 Response.End ,这会导致响应停止在该方法中方法。因此,用户无法注销应用程序。
我感谢任何帮助。
I have a requirement where I need to check if the user clicks the logout button in the Master page and skip a method in content page.Because that method has Response.End which causes the Response to stop in that method. Due to this the user is not getting logout of the application.
I Appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为解决您的问题的一个非常简单的解决方案是,当用户单击注销按钮时,您将他重定向到注销页面,该页面处理页面加载中的注销并再次重定向到主页。
I think one of the very simple solution for your problem is when the user clicks logout button you redirect him to a logout page that handles the logout in the page load and redirect to the home page again.
假设您的注销按钮是 html 提交按钮,您可以通过检查请求罐数据来检查。例如,
您可以在母版页中添加一个公共方法来执行此类检查并在页面中访问该方法。例如,在主代码后面
然后在您的内容页面中,
如果您使用锚点或图像作为注销按钮,那么最好的方法是使用js设置一些隐藏字段,然后检查页面中隐藏字段的值。
编辑:这是一个实用程序方法,用于检查请求数据以确定是否由于某些服务器控件而发生回发(无论控件类型或按钮的
UseSubmitBehavior
属性如何) 。Assuming your logout button is html submit button, you can check that by inspecting request pot data. For example,
You can add a public method in your master page to do such check and access that in your page. For example, in master code behind
And then in your content page,
In case, you are using anchor or image for logout button then the best way is to set some hidden field using js and then check the value of hidden field in the page.
EDIT: Here's a utility method that checks the request data to decide if post-back has happened due to some server control (regardless of control type or regardless of button's
UseSubmitBehavior
property).