Click here to Skip to main content
16,021,417 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is my regitration model :-

public class RegisterViewModel
   {
       [Required]
       [EmailAddress]
       [Display(Name = "Email")]
       public string Email { get; set; }
       public string FirstName { get; set; }
       [Required]
       public string MiddleName { get; set; }
       [Required]
       public string LastName { get; set; }
       [Required]
       public string Gender { get; set; }
       [Required]
       [DataType(DataType.Date)]
       public string DOB { get; set; }
       public string Profile { get; set; }
       [Required]
       [RegularExpression("^[0-9]{12}$")]
       public decimal Mobile { get; set; }
       [Required]
       public string Address { get; set; }
       [Required]

       public string City { get; set; }
       [Required]

       public string State { get; set; }


       [Required]
       [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
       [DataType(DataType.Password)]
       [Display(Name = "Password")]
       public string Password { get; set; }

       [DataType(DataType.Password)]
       [Display(Name = "Confirm password")]
       [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
       public string ConfirmPassword { get; set; }
   }



here :-

public string Profile { get; set; }
is the property where i want to store the path of image

here is my controller :-

private ApplicationDbContext db = new ApplicationDbContext();

       // GET: /Account/Register
       [AllowAnonymous]
       public ActionResult Register()
       {
           ViewBag.state = db.allofstate.Select(C => new SelectListItem
           {
               Value = C.States,
               Text = C.States
           }).ToList();
           return View();
       }

       //
       // POST: /Account/Register
       [HttpPost]
       [AllowAnonymous]
       [ValidateAntiForgeryToken]
       public async Task<ActionResult> Register(RegisterViewModel model)
       {
           if (ModelState.IsValid)
           {
               var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, MiddleName = model.MiddleName, LastName = model.LastName, Gender = model.Gender, DOB = model.DOB, Profile = model.Profile, Mobile = model.Mobile, Address = model.Address, City = model.City, State = model.State };
               var result = await UserManager.CreateAsync(user, model.Password);
               using (ApplicationDbContext db = new ApplicationDbContext())

               if (result.Succeeded)
               {
                   await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                   // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                   // Send an email with this link
                   // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                   // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                   // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                   return RedirectToAction("Index", "Home");
               }
               AddErrors(result);
           }

           // If we got this far, something failed, redisplay form
           return View(model);
       }


What I have tried:

i have tried with using byte but i want to store images path

because i want to retrive that image when perticular user logs in
Posted
Updated 5-Mar-17 8:40am
Comments
Bryian Tan 5-Mar-17 21:39pm    
Where is the actual images are sitting at? At a folder on the server?

1 solution

 
Share this answer
 

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