I hope you can help me with this topic, I am working on a project with asp.net c #, the problem is that I need to click on a label to execute a Json and it ends the session.
I explain to you what I did.
I have a VSesion class that has several methods, but the one that concerns me today is RestartSession.
public static void ReiniciarSesion()
{
HttpContext.Current.Session.Abandon();
HttpContext.Current.Response.Redirect(Resources.SitePages.Login);
}
In my Template.Master.cs I call the previous method in this way.
[WebMethod]
public static void ReiniciarSession()
{
VSesion.ReiniciarSesion();
}
In the Template.Master I call it this way..this is where I have the problem.
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#Reiniciar").click("click", function() {
ReiniciarSession();
});
});
function ReiniciarSession() {
$.ajax({
type: "POST",
url: "TemplateSae.Master/ReiniciarSession",
data: {},
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus + ": " + XMLHttpRequest.responseText);
}
});
}
</script>
Here the label
<ul>
<li>
<a href="#" id="Reiniciar">
<span>Salir</span>
</a>
</li>
</ul>
By the way and I forgot I'm using
<script src="JS/jquery.js" type="text/javascript"></script>
<script src="JS/jquery-1.11.3.min.js" type="text/javascript"></script>
I hope you can help me. Thanks. !!