There are two ways the session is tracked within ASP.NET (or for that matter, almost every framework). The first option are cookies, and the usual fallback option is URL-Rewriting.
AJAX calls do not, by default resend the cookies or the url-parameters, so in both cases you will have to be proactive.
Handling the first option (cookies are activated):
Reading cookies in javascript is done like: (the source for this code is w3schools, why reinvent the wheel?)
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
This method has another problematic edge which may be important, the session-id-cookie can be renamed in ASP.NET. Retrieving the name programmatically is possible, hava a look at stackoverflow: get session cookie name and for reasons why you would do such a thing have a look at stackoverflow: Reason to rename ASP.NET Session Cookie Name.
The default name (which will probably work for you) is:
ASP.NET_SessionId
Now, if getCookie didn't return anything, this doesn't mean the user is not logged in.
//EDIT - ASP.NET doesn't use parameters... How did I miss the contraditory source?
Well, now we have the SessionID, all we have to do to make the AJAX request working is rewriting the SessionID into the URL.
var SessionID = getCookie('ASP.NET_SessionId');
var urlprefix = "./";
if(SessionID != undefined)
urlprefix = "./(S(" + SessionID + ")/";
$.ajax({
type: "POST",
dataType: 'json',
url: urlprefix + 'delete.asp',
data: {"PartyId" : 550}
success: function (response) {
if(response.type == 'delete') {
alert('delete went ok');
}
},
error: function (event, request, settings) {
// alert('RESP:' + response + ' REQ: ' + request + ' SETTINGS' + settings);
},
});
Source: http://msdn.microsoft.com/en-us/library/ms178581.aspx