I have 'login' controller and action method defined:
[Route("Sign/{userName}/{password}")]
public ActionResult SignIn(string userName, string password)
{
bool result;
loginEntity.Email = userName;
loginEntity.Password = password;
result = loginBAL.UserLogin(loginEntity);
if (result)
{
var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Home");
return Json(new { Url = redirectUrl });
}
else
{
var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Login");
return Json(new { Url = redirectUrl });
}
}
Submit button to sign in:
Sign in
Ajax call to jump into 'login' contoller:
$(function () {
$("#btn").click(function () {
alert(window.location.host+"/Login/Sign" + "/" + $("#emailId").val() + "/" + $("#password").val());
$.ajax({
type: 'POST',
url: window.location.host + "/Login/Sign" + "/" + $("#emailId").val() + "/" + $("#password").val(),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
window.location.href = response.Url;
},
error: function () {
alert("Your Username & Password is wrong.");
window.location.href = response.Url;
}
});
El Mahdi ArchanePosted Jan 19, 2018, 5:21 AM
Dharmraj ThakurPosted Jan 17, 2018, 2:37 AM
For this change here it will work...
url: "/Login/SignIn/" + $("#emailId").val() + "/" + $("#password").val(),
Manav PandyaPosted Jan 16, 2018, 11:33 PM
meenakshi luthraPosted Jan 16, 2018, 11:22 PM
meenakshi luthraPosted Jan 16, 2018, 12:34 AM
meenakshi luthraPosted Jan 16, 2018, 12:12 AM
Suraj KumarPosted Jan 15, 2018, 11:57 PM