Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to modify this custom method to have additional fiels like LastName,Email and Isapproved.
Here is my complete code for user registration

C#
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();
                  }
          }
     }
 }
Thanks in advance for help..
Posted
Updated 20-Aug-13 11:48am
v2
Comments
Maciej Los 20-Aug-13 17:49pm    
And what's a question?
Sergey Alexandrovich Kryukov 20-Aug-13 20:20pm    
And which method? What is "custom method"? If yo want to modify any method, please go ahead, you got my approval.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900