TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
meenakshi luthra
NA
48
4.5k
Not able to call controller method
Jan 15 2018 11:49 PM
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.
Reply
Answers (
7
)
solve db.SaveChanges() exception MVC5
how to send bulk sms in batches of 100 sms using loop