单击“注销”按钮后,如何在会话中获取ID或任何用户详细信息 [英] How To Get Id Or Any User Details In Session After I Click On Logout Button
本文介绍了单击“注销”按钮后,如何在会话中获取ID或任何用户详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨团队,
我想在登录按钮之后点击退出按钮后,在会话中获取ID或任何用户详细信息。我怎么能得到它。我的代码如下:
Hi Team,
I want to get the ID or any user Details in session after i click on Logout button not after Login button.How I can i get it.I have the Code as follows:
#region Events
/// <summary>
/// The page losd event of Site master page.
/// </summary>
/// <param name="sender">The object sender.</param>
/// <param name="e">The event arguments.</param>
protected void Page_Load(object sender, EventArgs e)
{
if (Session[KaizenConstants.CURRENTLOGGEDINUSER] == null)
{
Response.Redirect("Login.aspx");
}
if (!IsPostBack)
{
if (Session[KaizenConstants.CURRENTLOGGEDINUSER] == null)
{
UserManagementController userManagementController = new UserManagementController();
IUserEntity user = UserManagementEntityCreator.GetUserEntity();
string userName = HttpContext.Current.User.Identity.Name;
user.NetworkId = userName.Substring(userName.IndexOf("\\") + 1);
currentUserID = user.NetworkId;
Result result = userManagementController.Get(user);
user = result.Entity as IUserEntity;
if (user.Id > 0)
{
Session[KaizenConstants.CURRENTLOGGEDINUSER] = result.Entity;
}
else
{
Response.Redirect("QCError.aspx");
}
}
}
}
在jquery中我有这样的代码:
In jquery I have Code like This:
$(function () {
$('#logButton').click(function () { Logout(); });
});
function Logout() {
debugger;
var currenturl = window.location.href;
$.ajax({
url: currenturl + '/Logout',
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: "json",
success: function (result) {
window.open('', '_self', '');
window.close();
},
error: function (error) {
window.open('', '_self', '');
window.close();
},
async: false
});
}
推荐答案
(function(){
(function () {
( '#logButton')。click(function(){Logout();});
});
函数Logout(){
debugger;
var currenturl = window.location.href;
('#logButton').click(function () { Logout(); }); }); function Logout() { debugger; var currenturl = window.location.href;
.ajax({
url:currenturl +'/ Logout',
type:'POST' ,
contentType:'application / json; charset = utf-8',
dataType:json,
success:function(result){
window.open('' ,'_ self','');
window.close();
},
错误:函数(错误){
window.open('','_ self' ,'');
window.close();
},
async:false
});
}
.ajax({ url: currenturl + '/Logout', type: 'POST', contentType: 'application/json; charset=utf-8', dataType: "json", success: function (result) { window.open('', '_self', ''); window.close(); }, error: function (error) { window.open('', '_self', ''); window.close(); }, async: false }); }
这篇关于单击“注销”按钮后,如何在会话中获取ID或任何用户详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文