Avatar of wellwet
wellwet
 asked on

Have to use full url in ASP-XMLHTTP ?

Hi,
In the folder C:\Inetpub\wwwroot\Test\ I got file page1.asp and page2.asp. page1.asp includes
     Set xml = Server.CreateObject("Microsoft.XMLHTTP")
     xml.Open "POST", "http://127.0.0.1/Test/page2.asp", True
and it works fine. However, If I change to
     xml.Open "POST", "page2.asp", True
it cannot work.

Is there something I missed or we have to use the full url ?
ASP

Avatar of undefined
Last Comment
L00M

8/22/2022 - Mon
ddrudik

Is it that you would like to not hardcode the /test/ in the URL?
There's a longer way around that by parsing PATH_INFO but why not just include the full URL as you have?
wellwet

ASKER
Thank you.
First, are you sure we have to use the full url?
Because I need to move the code between defferent servers........
ddrudik

127.0.0.1 will be the same on any server, that is a loopback address that always refers to the computer on which it is called.  If you will move it into another folder then that is handled by PATH_INFO.  Your testing showed that the above is true, I just assumed you tested correctly.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
L00M

I'm not sure why it's forcing you to provide a full path.
You may want to try '/test/page2.asp' as the path.

Otherwise, you could include 'settings.asp' at the top of the page.
Settings.asp:
<%
Dim xmlpath
xmlpath = "'http://127.0.0.1/Test/"
%>

Then, in code do:
 xml.Open "POST", <% = xmlpath %>"page2.asp"

Then you would only need to change the path in the settings file.
I hope that helps.
wellwet

ASKER
I want you confirm that we have to or not have to use the full url, because I  think my test might be wrong. I know in Javascript in client side, we can use only the file name if it is in the same folder as the calling file.
ddrudik

If this fails then you need to use the full path:
     Set xml = Server.CreateObject("Microsoft.XMLHTTP")
     xml.Open "POST", "page2.asp", True

I wouldn't think you should have to use the full path, but I guess if the above fails for you then you do need to use the full path.

The line:
     xml.Open "POST", "http://127.0.0.1/Test/page2.asp", True

Which references the loopback address of the server could be problematic when moving to another server if the server you are moving to is a server on which many websites exist on different IP addresses, in that case 127.0.0.1 would not necessarily work for your web site.

I would try to use:
     xml.Open "POST", "page2.asp", True

And if that failed, try to find out the local IP address assigned to the web site and replacing 127.0.0.1 with that local IP address.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
wellwet

ASKER
Thank you.

If any expert can test it or point any example in the web sites to confirm we have to use full url?
I just hate to parse the current url and join to the target file name. Why I can use only file name in Javascript client side but not in ASP?
ASKER CERTIFIED SOLUTION
L00M

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.