Asp.net mvc 登录+;在没有aspnet_*表的情况下注销?

Asp.net mvc 登录+;在没有aspnet_*表的情况下注销?,asp.net-mvc,Asp.net Mvc,我想知道是否有一种简单的方法可以不使用aspnet_*表以及所有这些来向mvc应用程序添加登录/注销功能?我需要一个简单的自定义登录+注销功能,让我的应用程序可以使用所有这些功能是没有意义的 /M您可以使用以下内容: public ActionResult Login(string userName, string password, string returnUrl) { if (AuthenticationHelper.Authenticate(userName, password)

我想知道是否有一种简单的方法可以不使用aspnet_*表以及所有这些来向mvc应用程序添加登录/注销功能?我需要一个简单的自定义登录+注销功能,让我的应用程序可以使用所有这些功能是没有意义的


/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");
        }
    }
}

Authenticate方法检查数据库

有没有什么方法可以让我把喜欢的[MyAuth]放在动作结果上?那个助手看起来怎么样?会话或?在Authenticate方法中,如果数据库检查成功,则运行以下操作:FormsAuthentication.SetAuthCookie(userID,false);用户id是与用户关联的唯一id。cookie将由ASP.NET自动生成。