Castle monorail monorail c中的登录功能#
有谁能给我一个好的链接来登录monorail c#的功能吗 我是monorail c#的新手,需要实现一个登录功能 多谢各位Castle monorail monorail c中的登录功能#,castle-monorail,Castle Monorail,有谁能给我一个好的链接来登录monorail c#的功能吗 我是monorail c#的新手,需要实现一个登录功能 多谢各位 Mealea与Ayende的解决方案类似,最好的方法就是使用ASP.net身份验证机制。下面是LoginController上的一个示例操作: [AccessibleThrough(Verb.Post)] public void Authenticate(string username, string password, bool autoLogi
Mealea与Ayende的解决方案类似,最好的方法就是使用ASP.net身份验证机制。下面是LoginController上的一个示例操作:
[AccessibleThrough(Verb.Post)]
public void Authenticate(string username, string password, bool autoLogin, string returlUrl)
{
SomeWebServiceAuthenticationProvider wsSecurity = new SomeWebServiceAuthenticationProvider();
bool isValid = wsSecurity.ValidateUser(username, password);
if (isValid)
{
//first perform a logout to make sure all other cookies are cleared
InternalLogout();
FormsAuthentication.SetAuthCookie(username, autoLogin);
PropertyBag["username"] = username;
PropertyBag["password"] = password;
PropertyBag["autoLogin"] = autoLogin;
//redirect back to the Home page, or some other page
if (!RedirectToPreviousUrl()) Redirect("home", "index");
}
else
{
Flash["auth_error"] = "Invalid user name or password.";
RedirectToAction("Index");
}
}
您可以用其他身份验证机制代替“SomeWebServiceAuthenticationProvider”……这里的重点是我们只是调用标准的FormsAuthentication方法。Mealea,您能选择一个答案吗?这个问题已经讨论了一段时间了。