Am i trying to create the functionality for sign up page but something is going wrong...am not getting any hit..can any one help me what's going wrong in my code...
[HttpPost]
public ActionResult Index(Users model)
{
using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatContext"].ConnectionString))
{
var cmd = new SqlCommand("USp_InsertUsers", con);// Give The command to SqlCommand
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar)).Value = model.UserName.Trim();
cmd.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar)).Value = model.Email.Trim();
cmd.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar)).Value = model.Password;
try
{
if (con.State != ConnectionState.Open)
con.Open();
cmd.ExecuteNonQuery();
ViewBag.message = "Account Created";
return View();
}
finally
{
if (con.State != ConnectionState.Closed)
con.Close();
}
}
return View("Index");
}
<div class="forgot-box-b">
<h3>User Signup</h3>
@using (Html.BeginForm("Index", "Register", FormMethod.Post, new { id = "registerForm" }))
{
<form action="" method="post">
<input type="name" placeholder="Username" class="margin" name="username" id="username" />
@Html.ValidationMessageFor(model => model.UserName)
<label id="lblname"></label>
<input type="email" placeholder="Email ID" class="margin" name="email" id="email"/>
@Html.ValidationMessageFor(model => model.Email)
<label id="lblemail"></label>
<input type="password" placeholder="Password" class="margin" name="password" id="password"/>
@Html.ValidationMessageFor(model => model.Password)
<label id="lblpswd"></label>
<input type="password" placeholder="Confirm Password" class="margin" name="confirm" id="confirm" />
<label id="lblcpswd"></label>
<input type="submit" value="submit" id="submit" name="submit" />
<!--<a href="#" class="a1">Sign up now</a><a href="#" class="a2">Forgot Password</a>-->
</form>
}
</div>