Hello everyone i am creating a login page using mvc4 wherein the login credentials are fetched from the database. In the database the relevant table contains 3 columns namely: userid, password and partnerid. When the user enters his credentials and clicks submit button, and if the login is successful, he is taken to a page whose address is like this :
http://localhost:58361/Home?result1=true
this is my submit button code:
<input type="submit" value="Login" class="login_button" onclick="return validateLoginPage()" />
here validateLoginPage is a js function which checks whether any input fields are not left blank.
My requirement is that on click of submit button the address of the page to which the user is redirected be shown like this:
http://localhost:58361/Home?result1=true?partnerid='somevalue'
The partnerid value is taken from the database and stored in a ViewData
how to achieve this? Thanks in advance
EDIT
This is the actionresult for the submit button
public ActionResult Index(LoginModel model,string res)
{
LoginUser = model.Userid;
LoginPassword = model.Password;
verify(LoginUser, LoginPassword);
res = result;
if (res == "true")
{
return RedirectToAction("Index", "Home", new { result1 = result });
}
else
{
ViewData["alert"] = "The Login Credentials are Incorrect";
return View();
}
}
The verify method verifies with the database whether the login credentials are correct or not and returns the string value “result” as true or false
If I understand you correctly, you want to submit a form that directs user to
I interpret that as going to Home Controller with null action (defaulting to Index) and passing result1=true always, and partnerid from ViewData
Warning: As Karthik has consderately pointed out, this code is untested. It’s more to demonstrate the point: