I am attempting to adapt the code in the FAQ here:
I want to have a ASP.NET login with links back to classic ASP. I made a .NET page (localmachine/ClassicSessionSync.aspx) that sets up the session variables into form elments and post it to a page (dev_intranet/DotNetSessionSync.asp) on the classic site page I made to take those elements and make them classic session variables. If I navigate to ClassicSessionSync.aspx, it works as expected.
Now, I tried using Ajax to call ClassicSessionSync.aspx and I have all sorts of problems. First of all, it returns 404 for me no matter how I put the address in. Is this caused by the fact that I'm posting to not only another page, but another server?
here is the javascript:
I also tried running the page like this (called from a Page_Load event:
Am I trying to do something that just plain isn't allowed?
Please pardon my ignorance and I look forward to any assistance anyone can offer.
I want to have a ASP.NET login with links back to classic ASP. I made a .NET page (localmachine/ClassicSessionSync.aspx) that sets up the session variables into form elments and post it to a page (dev_intranet/DotNetSessionSync.asp) on the classic site page I made to take those elements and make them classic session variables. If I navigate to ClassicSessionSync.aspx, it works as expected.
Now, I tried using Ajax to call ClassicSessionSync.aspx and I have all sorts of problems. First of all, it returns 404 for me no matter how I put the address in. Is this caused by the fact that I'm posting to not only another page, but another server?
here is the javascript:
Code:
var xhr = false;
var vdivID;
function displayResults(vDivID) {
// set divID that will update
vdivID = vDivID;
var url = "[URL unfurl="true"]http://localVirtualDirectory/V2/Common/ClassicSessionSync.aspx";[/URL]
makeRequest(url);
return false;
}
function makeRequest(url) {
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else {
if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) { }
}
}
if (xhr) {
xhr.onreadystatechange = showContents;
xhr.open('GET', url + '&ms=' + new Date().getTime(), true); //+'?ms='+ new Date().getTime() keeps from caching
xhr.send(null);
}
else {
document.getElementById(divID).innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
}
}
function showContents() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var outMsg = "Remote Login Complete";
}
else {
var outMsg = "There was a problem with the request " + xhr.status;
}
$(vdivID).innerHTML = outMsg;
}
}
I also tried running the page like this (called from a Page_Load event:
Code:
protected void SessionSync()
{
bool returnValue;
string url = "[URL unfurl="true"]http://localVirtualDirectory/V2/Common/ClassicSessionSync.aspx";[/URL]
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "HEAD";
try
{
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
returnValue = (response.StatusCode == HttpStatusCode.OK);
}
}
catch (WebException)
{
returnValue = false;
}
}
Am I trying to do something that just plain isn't allowed?
Please pardon my ignorance and I look forward to any assistance anyone can offer.