Hi Guys,
I have simple register page and unable to save to db using ASP.NET core MVC, below is my code
[HttpPost] public IActionResult Index(Registration registration) { if(ModelState.IsValid) { _context.Registration.Add(registration); _context.SaveChanges(); } return View(registration); }
@model GOMLIB.Models.Registration<div class="row"><div class="col-xl-12"><div class="card"><div class="card-body"><h4 class="header-title text-yellow">REGISTER WITH US</h4> @*<p class="sub-header"> Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs</p>*@ @using (Html.BeginForm()) { <div class="form-group mb-1 mt-3"><div class="input-group"><input type="email" class="form-control" placeholder="Enter email address" required parsley-type="email" aria-label="Enter email address"><div class="input-group-append"><input class="btn btn-info waves-effect waves-light" type="submit" value="Register" /></div></div></div> }</div></div></div></div>
using System; using System.Collections.Generic; using System.Text; namespace GOMLIB.Models { public partial class Registration { public int Registrationid { get; set; } public string Email { get; set; } public DateTime Createddate { get; set; } } }
Thanks,
Shabbir