2011-12-13 24 views
0

我正在使用ASP.NET成員資格提供程序的應用程序。默認情況下,我可以使用幾個字段,如用戶名,密碼。如何添加到asp.net成員資格提供程序,以便我可以在註冊部分添加配置文件字段,如「firstName」,「lastName」,並將其保存到aspnet_profile表中的數據庫以及其他數據。如何使用ASP.Net成員資格提供程序添加個人資料字段?

public ActionResult Register(RegisterModel model) 
    { 
     if (ModelState.IsValid) 
     { 
      // Attempt to register the user 
      MembershipCreateStatus createStatus; 
      Membership.CreateUser(model.UserName, model.Password, 
      model.Email,model.PasswordQuestion,model.PasswordAnswer, 
      true, null,out createStatus); 
      if (createStatus == MembershipCreateStatus.Success) 
      { 
       FormsAuthentication.SetAuthCookie(model.UserName, false); 
       return RedirectToAction("Index", "Home"); 
      } 
      else 
      { 
       ModelState.AddModelError("", ErrorCodeToString(createStatus)); 
      } 
     } 

     return View(model); 
    } 

現在哪個函數,我應該用它來存儲個人資料信息到數據庫:

,我在下面的帳戶模式創建用戶? 幫幫我!

回答

3

將字段添加到Web.Config的配置文件部分。

<profile> 
<properties> 
    <add name="FirstName" /> 
    <add name="LastName" /> 
    <add name="Address1" /> 
    <add name="Address2" /> 
    <add name="City" /> 
    <add name="State" /> 
    <add name="Zip" /> 
    <add name="Phone" /> 
    <add name="ProfileVersion" type="int" defaultValue="0" /> 
    </properties> 
</profile> 

欲瞭解更多信息,請訪問:http://msdn.microsoft.com/en-us/magazine/cc163457.aspx

+0

它不是在MVC工作。它在asp.net web窗體中工作! – Vishal

相關問題