Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
7
Reply
Not able to call controller method
meenakshi luthra
Jan 15 2018 11:49 PM
198
Reply
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:
<button type="submit" id="btn" class="btn btn-primary">
Sign in
</button>
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;
}
});
I am not able to call SignIn action method using this ajax call. Please let me know where is the issue or how to over come this problem.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
solve db.SaveChanges() exception MVC5
how to send bulk sms in batches of 100 sms using loop