0
下面我有一個登錄功能:如何創造登錄會話,並保存登錄狀態
[WebMethod]
public static bool isAccountAvailable(string userName, string passWord)
{
BDTestDataContext bdc = new BDTestDataContext();
if ((from q in bdc.Accounts where q.User == userName && q.Password == passWord select q).Count() > 0)
return true;
else
return false;
}
和jQuery
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'Home.aspx/isAccountAvailable',
data: JSON.stringify({ userName: $('#txtUserLogin').val(), passWord: $('#txtPassLogin').val() }),
dataType: 'json',
success: function (data) {
if (data.d == true) {
alert("Login success");
}
else
alert("Error!");
}
});
我想創造會話保存登錄狀態,當我打開另一個頁面。例如:/manager.aspx
我想獲得用戶名,怎麼辦?兄弟,幫幫我吧! – ThinhSwen
你想在webmethod或js中獲得用戶名的地方? –
Js,Bro plz .... – ThinhSwen