PDA

View Full Version : Post Method XMLhttprequest Forces Login Dialog(IE issue)


dashrendaer
05-26-2010, 08:01 PM
We are running windows iis and use it's native ability to protect files as our login method.

It works fine, except that when I try to post an post method XMLHttpRequest from IE i get the login dialog again, which causes the request to fail.
The weird thing is that Mozilla works fine.

Is there something I can do with the headers or something to make IIS recognize it as the same session, and not promt a re-login?


function ajaxQuery(method,url,params,asynchronous,readyFunction,is_done){
if(asynchronous == null){
asynchronous = true;
}
//alert("URL: "+url);
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
readyFunction(xmlhttp.responseText);
if(is_done){
is_done("ok");
}
}
}
if(method.toLowerCase() == "get"){
url += "?"+params;
params = null;
}
debug = url;
xmlhttp.open(method,url,asynchronous);
if(method.toLowerCase() == "post"){
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
debug = params.length;
}
xmlhttp.send(params);
}

dashrendaer
05-26-2010, 08:53 PM
More Info:
Server:
IIS 6
Windows Authentication

Browsers:
IE8 & IE8 Compatability mode: prompt for re-login on post method xml request.
Mozilla Firefox and Safari: No issues; Working splendidly.

dopefish
07-29-2010, 03:49 PM
Late reply, I know, but maybe it will still help... Check the response headers for the URLs you're XmlHttpRequest'ing that are exhibiting this issue.

We had the same problem with a session-check script. It turned out IIS was catching our (intentional) 401 response codes and adding the WWW-Authenticate header which caused IE to display the login dialog.

Fortunately, we were simply able to switch the response code we generated to 403, which still made sense contextually and IIS let pass unchanged.

Jenny Dithe
10-23-2010, 08:22 AM
I think this is my problem too. Could you dumb down a little bit your explanation for me.