title: ASP.Net MVC 3 Membership.UpdateUser(MembershipUser user)
body: <p>i have a project that use MVC3. in my project, i have a page that user can edit their account (UserComment, UserEmail, IsLocked, IsApproved). i already make the View for Edit Account. i have some trouble to make the Edit Controller.
  here's my code:    </p>
  
  <pre><code>    [HttpPost]
      public ActionResult Edit(string id, FormCollection collection)
      {
          id = id.Replace("+", " ");
          var user = Membership.GetUser();
          Guid UserGUID = new Guid(user.ProviderUserKey.ToString());
          var SysUser = db.System_User.Single(u =&gt; u.User_UserId == UserGUID);
  
          //this is for updating User Office in my System_user table
          SysUser.User_Office = collection["SysUsers[0].UserOffice"];
  
          //this is for updating User Account in aspnet_membership table
          user.UserName = collection["SysUsers[0].UserName"];
          Membership.UpdateUser(user);
  
          user.Comment = collection["SysUsers[0].UserComment"];
          Membership.UpdateUser(user);
  
          user.Email = collection["SysUsers[0].UserEmail"];
          Membership.UpdateUser(user);
  
          return View();
      }
  </code></pre>
  
  <p>when i run my controller, i get some error like :</p>
  
  <ol>
  <li>user.UserName is read only, i cant update this one.</li>
  <li>i get user.Comment value, but its not update.</li>
  <li>i get error in my Edit View, it says "Object reference not set to an instance of an object." 
    @using (Html.BeginForm("edit/" + @Model.SysUsers[0].UserID, "cpanel/sysuser", FormMethod.Post))</li>
  </ol>
  
  <p>can anyone help me ? </p>
  
  <p>thanks, </p>