2009-07-22 2 views
1

モノレールの機能にログインするためのリンクがありますか?モノレールのログイン機能C#

私はモノレールC#の初心者で、1つのログイン機能を実装する必要があります。

ありがとうございます。 Ayendeの溶液中で同様

Mealea

答えて

1

、最良の方法は、単に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メソッドを呼び出しているということです

+0

Mealeaあなたは答えを選ぶことができますか?この質問はしばらくの間座っています。 – Marc

関連する問題