I have a jquery function:
function ExpireSession() {
$.ajax({
type: "POST",
url: '@Url.Action("LogOffSession","Account")',
dataType: "json",
success: function (data) {
},
error: function (data) {
}
});
}
The action method that is called from the above function is:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOffSession()
{
Session.Abandon();
FormsAuthentication.SignOut();
return Json(new { result = true });
}
The jquery function is called(i tested with an alert) but the action method is not being called. I tried giving something in success and error functions but no effect.
I also tried by giving the jquery function like this
function ExpireSession() {
var url = '@Url.Action("LogOffSession", "Account")';
$.post(url, null, function (data) {
return true;
});
but still it is not working.
What is that I am doing wrong?