我在下面有一个登录功能:
[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