我在ASP.NET网站中使用表单身份验证,我需要检查用户是否已通过身份验证,然后再在客户端进行回调,我该如何使用JavaScript / jQuery?
You need to define a webmethod to check the session status and then have a .ajax query the method.
[WebMethod]
public static string GetSession(string Skey)
{
return Session[Skey];
}
[WebMethod]
public static string SetSession(string key, string Svalue)
{
Session[key] = Svaluee;
}
jQuery:
$.ajax({
type: "POST",
url: "website.aspx/GetSessionValue",
data: '{ key: "CurrentSessionKey" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
console.log("The Session value is " + data);
}
});
Read the question wrong. Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.