I have a problem when debug the code..User had been registered the field and it got to another page. But when go to the another page, all the parameter were include in URL.. example: http://localhost:56767/Pendaftaran/VerifyEmail?Role=3&FirstName=Abu&LastName=Mutalib&ICNumber=8812511469&Gender=1&Email=abu%40gmail.com&Password=aaabbb&ConfirmPassword=aaabbb&State=16&MobileNumber=012-7415511
This is using stored procedured database on sql server.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult AddParticipant(RegistrationModel obj)
{
try
{
if (ModelState.IsValid)
{
if (this.IsCaptchaValid("Captcha is not valid")) //Added Captcha 17 May 2019 -Aidil-
{
if (obj.Role == 2) //Add if else for club 17 May 2019 -Aidil-
{
if (obj.CLubRegistration != null)
{
//Add Stored Procedured -Aidil- 15 May 2019
connection();
SqlCommand com = new SqlCommand("uspRegisterParticipant", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Role", obj.Role);
com.Parameters.AddWithValue("@ClubReg", obj.CLubRegistration); //Added ClubRegistration 16 May 2019 -Aidil-
com.Parameters.AddWithValue("@FirstName", obj.FirstName);
com.Parameters.AddWithValue("@LastName", obj.LastName);
com.Parameters.AddWithValue("@ICNumber", obj.ICNumber);
com.Parameters.AddWithValue("@Gender", obj.Gender);
com.Parameters.AddWithValue("@Email", obj.Email);
com.Parameters.AddWithValue("@Password", obj.Password);
com.Parameters.AddWithValue("@State", obj.State);
com.Parameters.AddWithValue("@MobileNumber", obj.MobileNumber); //Added MobileNumber 16 May 2019 -Aidil-
con.Open();
int i = com.ExecuteNonQuery();
con.Close();
//End Added Stored Procedured -Aidil- 15 May 2019
}
}
else
{
connection();
SqlCommand com = new SqlCommand("uspRegisterParticipant", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Role", obj.Role);
com.Parameters.AddWithValue("@FirstName", obj.FirstName);
com.Parameters.AddWithValue("@LastName", obj.LastName);
com.Parameters.AddWithValue("@ICNumber", obj.ICNumber);
com.Parameters.AddWithValue("@Gender", obj.Gender);
com.Parameters.AddWithValue("@Email", obj.Email);
com.Parameters.AddWithValue("@Password", obj.Password);
com.Parameters.AddWithValue("@State", obj.State);
com.Parameters.AddWithValue("@MobileNumber", obj.MobileNumber); //Added MobileNumber 16 May 2019 -Aidil-
con.Open();
int i = com.ExecuteNonQuery();
con.Close();
//End Added Stored Procedured -Aidil- 15 May 2019
}
return RedirectToAction("VerifyEmail", obj); //Update RedirectAction 27 May 2019 -Aidil-
}
ViewBag.ErrMessage = "Error: captcha is not valid.";
//return View();
}
return View();
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
return View();
}
}
// GET: Pendaftaran/VerifyEmail
//Added VerifyEmail 27 May 2019 -Aidil-
[HttpGet]
public ActionResult VerifyEmail(EmailVerificationModel obj)
{
try
{
//Add Stored Procedured -Aidil- 27 May 2019
connection();
SqlCommand com = new SqlCommand("uspDisplayNameForVerification", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@FirstName", obj.FirstName); //Added called from AddParicipant 28 May 2019 -Aidil-
com.Parameters.AddWithValue("@LastName", obj.LastName); //Added called from AddParicipant 28 May 2019 -Aidil-
con.Open();
//int i = com.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(com);
con.Close();
return View(obj); //Update view () to view(obj) -Aidil- 29 May 2019
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
return View();
}
}
//End Added VerifyEmail 27 May 2019 -Aidil-
}
Supposedly i want show only this : http://localhost:56767/Pendaftaran/VerifyEmail?Role=3
EmailVerificationModel? Anyway, not sure why you are using SPs and doing this with custom code. Why not start with built in helpers and work from there? I really don't see a need for SP here. - kovac