0
我想知道是否有一个简单的方法不使用aspnet_ *表和所有这些添加登录/注销功能的mvc应用程序?我需要一个简单的自定义登录+注销功能,并且为我的应用程序提供所有这些功能是没有意义的。登录+注销无aspnet_ *表?
/M
我想知道是否有一个简单的方法不使用aspnet_ *表和所有这些添加登录/注销功能的mvc应用程序?我需要一个简单的自定义登录+注销功能,并且为我的应用程序提供所有这些功能是没有意义的。登录+注销无aspnet_ *表?
/M
您可以使用这样的事情:
public ActionResult Login(string userName, string password, string returnUrl)
{
if (AuthenticationHelper.Authenticate(userName, password))
{
if (!String.IsNullOrEmpty(returnUrl) && returnUrl != "/default.aspx")
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
}
的对数据库进行身份验证方法检查。
是否有某种方式可以让我可以将[MyAuth]放在动作结果上?那帮助人怎么看?会话是什么或? – 2010-01-20 09:23:05
在Authenticate方法中,如果数据库检查成功,则运行以下命令: FormsAuthentication.SetAuthCookie(userID,false); userID是您与用户关联的唯一ID。 Cookie将由ASP.NET自动生成。 – stepanian 2010-01-20 09:30:20