替换过时的FormsAuthentication.Authenticate

时间:2014-04-01 06:55:00

标签: c# asp.net obsolete

Visual Studio 2012警告此类的第一行已过时:

  

if(FormsAuthentication.Authenticate(UserName.Text,Password.Text)==   真)

 public void LoginClass(object s, EventArgs e)
{
    if (FormsAuthentication.Authenticate(UserName.Text, Password.Text) == true)
    {
        FormsAuthentication.SetAuthCookie(UserName.Text, true);
        Response.Redirect("admin/default.aspx");
    }
    else
    {
        if (DBAuthenticate(UserName.Text, Password.Text))
        {
            FormsAuthentication.SetAuthCookie(UserName.Text, true);
            Response.Redirect("members/default.aspx");
        }
        else
        {
            LtlLogin.Text = "<p>Sorry wrong login details</p>";
        }
    }

}

我很感激一些帮助。我应该在框架4.5中替换这样的代码行?

1 个答案:

答案 0 :(得分:0)

错误消息本身或MSDN参考页面确实向您展示了要使用的新API,因此我认为您不需要帮助,但我们可以帮助您自己,

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.authenticate(v=vs.110).aspx