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;
}
});

Suraj KumarRank #353 · 7.1K reputationPosted Jan 15, 2018, 6:57 PM EST
meenakshi luthra51 reputationPosted Jan 15, 2018, 7:12 PM EST
meenakshi luthra51 reputationPosted Jan 15, 2018, 7:34 PM EST
meenakshi luthra51 reputationPosted Jan 16, 2018, 6:22 PM EST
Manav PandyaRank #166 · 14.3K reputationPosted Jan 16, 2018, 6:33 PM EST
El Mahdi ArchaneRank #431 · 5.8K reputationPosted Jan 19, 2018, 12:21 AM EST
Dharmraj ThakurRank #577 · 4.2K reputationPosted Jan 16, 2018, 9:37 PM EST
For this change here it will work...
url: "/Login/SignIn/" + $("#emailId").val() + "/" + $("#password").val(),