Wasfa Anjum

Wasfa Anjum

  • NA
  • 1
  • 1k

Modifying Custom CreateUser method in mvc

Aug 19 2013 1:50 AM
I want to modify this custom method to have additional fiels like LastName,Email and Isapproved.


Here is my complete code for user registration

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using MVCLogin.Models;

namespace Recaptcha
{
  namespace MVCLogin.Controllers
  {
  public class AccountsController : Controller
  {
  //
  // GET: /Accounts/

  public ActionResult Index()
  {
  return View();
  }
   [HttpGet] 
   public ActionResult Login()
  {
  return View();
  }
   [HttpPost]
  public ActionResult Login()
   {
   return View();
  }
  [HttpGet]
  public ActionResult Registeration()
  {
  if  (!WebSecurity.Initialized)
  {
   WebSecurity.InitializeDatabaseConnection("MVCLoginConStr",
  "Authentication", "UserId", "FirstName", autoCreateTables: true);
  }
  return View();
  }

  [HttpPost, RecaptchaControlMvc.CaptchaValidatorAttribute]
   public ActionResult Register(Registration model, bool captchaValid)
   {
  if (!captchaValid)
   {
  ModelState.AddModelError("", "You did not type the verification 
  word correctly. Please try again.");
   } //if
   else
  {
  if (ModelState.IsValid)
   {
  // Attempt to register the user
   MembershipCreateStatus createStatus;
   Membership.CreateUser(model.FirstName,model.Password,
   model.Email, null, null, true,null,out createStatus);
   if (createStatus == MembershipCreateStatus.Success)
  {
  FormsAuthentication.SetAuthCookie(model.FirstName, false);
  return RedirectToAction("Index", "Home");
  }//if
  else
  {
   ModelState.AddModelError(string.Empty, "Your error Message");
   }//else
  }//if
  } //if  
   // If we got this far, something failed, redisplay form
  return View(model);
  } //register
   public ActionResult Confirmation()
   {
  return View();
   }
   }
   }
   }//recpatcha

Thanks in advance for help..

Answers (1)