Connecting Tech Pros Worldwide Forums | Help | Site Map

Accessing .asp subroutines remotely

Newbie
 
Join Date: Jun 2007
Posts: 26
#1: May 2 '09
Hi,

I need to access an .asp subroutine file from a subdomain.

i.e. the website is at www.domain.com and I want to access the same subroutines on the subdomain mobile.domain.com.

The normal #include and #virtual don't seem to be working remotely.

I have also tried:

url = "http://<domain>/subroutines.asp"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
Response.write xmlhttp.responseText
set xmlhttp = nothing

and it doesn't error out, but the subroutines don't seem to be accessible.

Ideas? thanks.

jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: May 4 '09

re: Accessing .asp subroutines remotely


actually sounds like a server issue to me. Let me ask an IIS expert to weigh in.

Jared
Denburt's Avatar
Moderator
 
Join Date: Mar 2007
Location: Louisiana
Posts: 1,218
#3: May 5 '09

re: Accessing .asp subroutines remotely


Yes this would be a server issue as an include tag such as this is called a Server Side Include or SSI. Do you have access to the servers directory structure or are you uploading to a remote server someplace? This is important, if it is the latter then there may be certain restrictions on what you can use and how you can use it. Such as using various file extensions and such.
It sounds as though you are trying to move up on the directory structure as such. <!--#include virtual="../header.html" -->
So it may be as simple as that a simple .. or ../../ for moving up two directories depending on where the file resides the server may require a full path name even it really depends on the server and the restrictions that they put on it and where the file resides in relation to the file that calls it.

here is a link that may help.
http://www.w3schools.com/asp/asp_incfiles.asp
Newbie
 
Join Date: Jun 2007
Posts: 26
#4: May 5 '09

re: Accessing .asp subroutines remotely


I have looked through your reply and tested out your suggestions. The problem is that my subdomain, even though it is physically located in a subdirectory, is treated as a completely separate entity. Therefore I can't access the subroutine file through a relative path. (

<!-- #include file ="../ActionFiles/subroutines.asp" -->

gives the error:

"The Include file '../ActionFiles/subroutines.asp' cannot contain '..' to indicate the parent directory. "

)

I am uploading to a remote server with a shared hosing package, so I don't have control over the server variables. Is there a setting I could ask support to change to allow me to include a remote file?

It looks to me like the problem is more that the .asp code won't execute. It does read in the file through the MSXML2.ServerXMLHTTP object, and if I take off the <% %> asp tags it will display the actual text. It just won't allow me to use the subroutines.

Is there a way I can specify for the read-in file to execute early enough to use those subroutines in the page?
Denburt's Avatar
Moderator
 
Join Date: Mar 2007
Location: Louisiana
Posts: 1,218
#5: May 5 '09

re: Accessing .asp subroutines remotely


You stated that it is in a sub directory so the two dots shouldn't be necessary that will only take you to the parent. You also stated that you can read text from an include of this sort so obviously you have the paths straight, now as to why you can't call the subroutines there could be a lot of reasons for that. If it is loading the file then you should be able to call the subroutines in it.
As to your question about the file that is read in and if you are calling it early enough yes it loads before any scripting on the page. Quoting from the link I posted earlier:
Quote:
Included files are processed and inserted before the scripts are executed.
You may have an error in the script or something there that is hanging it up I really can't say. If I were you I would try to break it up so that I only have one subroutine then add them each in one at a time till you see where it breaks. If need be start with something really simple call that and make sure it works then go from there.
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 145
#6: May 5 '09

re: Accessing .asp subroutines remotely


Couple of thoughts

Quote:
<!-- #include file ="../ActionFiles/subroutines.asp" -->

gives the error:

"The Include file '../ActionFiles/subroutines.asp' cannot contain '..' to indicate the parent directory. "
Would Enable Parent Paths in IIS cure that?

Also are the User credentials the same in the sub domain as they are in the root?
Newbie
 
Join Date: Jun 2007
Posts: 26
#7: May 6 '09

re: Accessing .asp subroutines remotely


Thanks for working at this with me.

Let me clarify my problem, correct me if I am wrong:

1) Subdomains are treated as separate entities by asp (as evidenced by the session variables not transferring).

2) Therefore using any sort of relative path shouldn't work.

3) So the path must be a complete address.

4) <!-- #include file="..."> and <!-- #include relative="..."> do not allow complete addresses, all paths must be relative.

5) So I have to read in the subroutine file via a different method.

6) The MSXML2.ServerXMLHTTP object will read the contents of the remote file that I want and execute them. (if I have a subroutine and a call to that subroutine in the remote file, it will execute.)

HOWEVER - I CANNOT CALL THE SUBROUTINES IN THE ORIGINAL PAGE.

My original page is treating the subroutines as if they do not exist. No errors, but no execution.

**And this is where I'm stuck.

Thanks.
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#8: May 6 '09

re: Accessing .asp subroutines remotely


Quote:

Originally Posted by liz0001 View Post

Thanks for working at this with me.

Let me clarify my problem, correct me if I am wrong:

1) Subdomains are treated as separate entities by asp (as evidenced by the session variables not transferring).

this is also not an ASP issue, but a server issue. It is the server that maps different directories to different websites. If you just made directories from the command line there is no reason an ASP page wouldn't recognize all of them as being in the same website. That said, I am aware that dreamweaver's implementation of ASP would separate each directory into its own website, and there are probably other programs that do that as well. If you don't have direct access to the server than there isn't much you can do about that, but I have done that type of thing many times.
Quote:
2) Therefore using any sort of relative path shouldn't work.

3) So the path must be a complete address.

4) <!-- #include file="..."> and <!-- #include relative="..."> do not allow complete addresses, all paths must be relative.

5) So I have to read in the subroutine file via a different method.

6) The MSXML2.ServerXMLHTTP object will read the contents of the remote file that I want and execute them. (if I have a subroutine and a call to that subroutine in the remote file, it will execute.)

HOWEVER - I CANNOT CALL THE SUBROUTINES IN THE ORIGINAL PAGE.

My original page is treating the subroutines as if they do not exist. No errors, but no execution.
for a real server-side include the include needs to be pulled up by the server BEFORE the asp is executed. that's why what you are trying to do won't work, you are pulling the text of the file in with ASP instead of before. This would be a terrible security risk, but you could theoretically open both files (the include and the asp file) in a separate asp page and merge them on the fly, then redirect to the newly merged file. This would accomplish the same thing as the include: the include file is accessed and linked to the asp page BEFORE the asp is run
Quote:
**And this is where I'm stuck.

Thanks.
Without more details it is hard to give better suggestions, but I am inclined to say that it sounds like a job for a web-service.

Jared
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 145
#9: May 6 '09

re: Accessing .asp subroutines remotely


Quote:
4) <!-- #include file="..."> and <!-- #include relative="..."> do not allow complete addresses, all paths must be relative.
To reiterate:

Setting Enable Parent Paths in IIS will allow the use of "../"

Gaz
Newbie
 
Join Date: Jun 2007
Posts: 26
#10: May 6 '09

re: Accessing .asp subroutines remotely


THANK YOU!! I was able to enable the parent paths and include the files!!
Denburt's Avatar
Moderator
 
Join Date: Mar 2007
Location: Louisiana
Posts: 1,218
#11: May 6 '09

re: Accessing .asp subroutines remotely


Very nice glad you've got it. If there is anything else we can do we'll be here.
Reply

Tags
remote subroutine