authenticationservice.cs
来自「AJAX开发工具包」· CS 代码 · 共 50 行
CS
50 行
/*
* MS 05-12-20 initial version
* MS 06-04-16 changed methods to static
*
*
*
*
*/
using System;
using System.Web.Security;
namespace AjaxPro.Services
{
[AjaxNamespace("AjaxPro.Services.Authentication")]
public class AuthenticationService
{
[AjaxMethod]
public static bool Login(string username, string password)
{
#if(NET20)
if(Membership.Provider.ValidateUser(username, password))
#else
if(FormsAuthentication.Authenticate(username, password))
#endif
{
FormsAuthentication.SetAuthCookie(username, false);
return true;
}
return false;
}
[AjaxMethod]
public static void Logout()
{
FormsAuthentication.SignOut();
}
[AjaxMethod]
public static bool ValidateUser(string username, string password)
{
#if(NET20)
return Membership.Provider.ValidateUser(username, password);
#else
throw new NotImplementedException("ValidateUser is not yet implemented.");
#endif
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?