MS XML HTTP REQUEST AND PATHS

V

vunet.us

Why ASP's MS XML HTTP request object gets another page's HTML source
without interpreting path differences. For example, if my page is:

www.test.asp/one/two/page1.asp

with XMLHTTP getting source code of page:

www.test.asp/one/page2.asp

and this latter page has a CSS with path ../include/css.css, it won't
be used in page1.asp because path will stay as it is "../include/
css.css", not "../../include/css.css" as needed for page1.asp?

So I only have one workaround to replace instances of ../ with ../../.
Any other suggestions or explanations?
Thank you
 
T

ThatsIT.net.au

Why ASP's MS XML HTTP request object gets another page's HTML source
without interpreting path differences. For example, if my page is:

www.test.asp/one/two/page1.asp

with XMLHTTP getting source code of page:

www.test.asp/one/page2.asp

and this latter page has a CSS with path ../include/css.css, it won't
be used in page1.asp because path will stay as it is "../include/
css.css", not "../../include/css.css" as needed for page1.asp?

So I only have one workaround to replace instances of ../ with ../../.
Any other suggestions or explanations?
Thank you

I don't like to use ../ at all, as it restricts mobility.
I always use a absolute path like /include/css.css

Do this and you will not have the problem
 
M

Mark J. McGinty

Why ASP's MS XML HTTP request object gets another page's HTML source
without interpreting path differences. For example, if my page is:

www.test.asp/one/two/page1.asp

with XMLHTTP getting source code of page:

www.test.asp/one/page2.asp

and this latter page has a CSS with path ../include/css.css, it won't
be used in page1.asp because path will stay as it is "../include/
css.css", not "../../include/css.css" as needed for page1.asp?

I assume you're talking about LINK tags in an HTML doc, that reference CSS
in an external file, (as opposed to a server-side #include) correct? Those
tags are interpreted by the browser, XMLHTTP doesn't interpret anything that
can't be parsed as well-formed XML, you are using it to download raw HTML
source, that was intended to be browsed from within the context of a given
web path.

This actually applies to any tag that has an href, src, action, or any other
attribute that the browser resolves to a URL. Any relative aspects of
referenced URLs will be resolved based upon the FQ URL of the document being
browsed, by the client browser.

Content acquired using XMLHTTP will have no reference to the location from
which it was originally acquired, to do it right, you'd need to resolve all
relative URLs to be fully-qualified, based on the location from which the
content was originally served.


-Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top