通过JavaScript调用FormsAuthentication.Signout方法 [英] Call FormsAuthentication.Signout method via JavaScript

查看:167
本文介绍了通过JavaScript调用FormsAuthentication.Signout方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我单击它时有一个注销按钮,我称之为formsauthentication.signout方法,它的工作原理很好,但是当我关闭浏览器选项卡而不按注销按钮时,用户会话仍然有效.我想生成该按钮事件或在通过javascript函数关闭浏览器选项卡时调用Formsauthentication.signout方法的任何建议.我知道我必须在bodyUnload中调用该javascript函数.任何机构都可以帮助我,即使在javascript中,我也必须写才能生成该按钮,我已经尝试过

var btn = document.getelementByid(<%LogoutButton%">
btn.click();

但它不起作用.任何建议

Hi

I have one log out button on the click of it i have called formsauthentication.signout method its works fine but when i closed Browser tab without pressing Logout button user session stays alive. what i want to generate that button event or call formsauthentication.signout method on closing of browser tab via javascript function any suggestions.I know that i have to call that javascript function in bodyUnload. any body help me what i have to write to generate that button even in javascript i have Tried

var btn = document.getelementByid("<%LogoutButton%">
btn.click();

but its not working. any suggestions

推荐答案

var btn = document.getelementByid("<%LogoutButton%">
btn.click();


这确实会启动,但是在调用Click时,该窗体已经关闭,因此该事件没有执行.因此,它不起作用.尝试放置一个延迟,以便可以发生onclick事件并查看.不过,我想通知您,处理浏览器关闭并不容易,也不是充分的证明.

另外,不要调用click,而要调用XMLHttpRequest并尝试注销.

BTW,会话和表单身份验证-两者不同.


This does initiate but by the time Click is called, the form is already closed and thus the event is not executed. Thus, it''s not working. Try to put a delay such that onclick event can occur and see. Though, I would like to inform, handling browser close is not easy and full proof.

Also, instead of calling click, try to call a XMLHttpRequest and try to signout.

BTW, session and forms authentication - Both are different.


这篇关于通过JavaScript调用FormsAuthentication.Signout方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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