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...
Controller:
[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");
}
View:
User Signup
@using (Html.BeginForm("Index", "Register", FormMethod.Post, new { id = "registerForm" }))
{
@Html.ValidationMessageFor(model => model.UserName)
@Html.ValidationMessageFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Password)
}

Saineshwar BageriRank #115 · 19.6K reputationPosted Jun 8, 2015, 10:31 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jun 8, 2015, 11:57 PM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted Jun 9, 2015, 11:22 PM EDT