SitePoint Sponsor |
|
User Tag List
Results 1 to 18 of 18
-
Oct 19, 2010, 15:23 #1
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
config.asp file to declare variables for include files
let me just start that I am an asp newb...
searched all over the internet for this answer and can't seem to find anything
I have a config.asp file (located on my server (ip_address/root/config.asp) that i am declaring a variable in:
Code:<% dim root_path root_path = "/rootfolder/" %>
a) is this the only way to include the config file in it? <!--#include virtual="/root/config.asp"-->
-b/c if that is the case, I would have to delete the /root out when i move from dev to prod (seems pointless)
b) can I include a declared variable in an include statement?
Code:<!--#include virtual="<%=root_path%>inc/header.asp"-->
Active Server Pages error 'ASP 0126'
Include file not found
/root/subfolder/default.asp, line 34
The include file '<%=root_path%>inc/header.asp' was not found.
If anyone can provide help, I would be very appreciative! I have scoured the internet for the past 2 business days looking for help...
-
Oct 19, 2010, 21:10 #2
- Join Date
- Apr 2009
- Posts
- 359
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Include files are merged into the page code base before any asp code starts running, so you can't make a dynamic path like you're trying to do. From IIS 5+ server.execute and/or server.transfer may offer a solution for you.
Doug G
=====
"If you ain't the lead dog, the view is always the same - Anon
-
Oct 20, 2010, 02:56 #3
- Join Date
- Oct 2002
- Location
- Scotland
- Posts
- 3,631
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Why not use relative file paths?
Code:<!-- #include file="../inc/header.asp" -->
-
Oct 20, 2010, 07:27 #4
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That ^ results in this error:
Active Server Pages error 'ASP 0131'
Disallowed Parent Path
/root/subfolder/default.asp, line 34
The Include file '../inc/header.asp' cannot contain '..' to indicate the parent directory.
It will not let me do:
Code:<!-- #include file="/inc/header.asp" -->
Active Server Pages error 'ASP 0130'
Invalid File attribute
/root/subfolder/default.asp, line 34
File attribute '/inc/header.asp' cannot start with forward slash or back slash.
And I cannot do:
Code:<!-- #include file="inc/header.asp" -->
-
Oct 20, 2010, 07:29 #5
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Oct 20, 2010, 12:19 #6
- Join Date
- Jun 2007
- Posts
- 691
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
simply deleting the /root out when you move from dev to prod doesn't seem like a big deal .....
-
Oct 20, 2010, 15:00 #7
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Oct 20, 2010, 18:51 #8
- Join Date
- Jun 2007
- Posts
- 691
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There are two ways to include files in ASP. With the "include file" or "include virtual" options.
your choice.
-
Oct 20, 2010, 19:08 #9
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Oct 21, 2010, 10:18 #10
- Join Date
- Jun 2007
- Posts
- 691
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Server.Execute drawbacks are discussed here:
http://docs.sun.com/source/817-2514-...uiltIn142.html
-
Oct 21, 2010, 17:27 #11
- Join Date
- Apr 2009
- Posts
- 359
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
-
Oct 22, 2010, 10:18 #12
- Join Date
- Jun 2007
- Posts
- 691
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's still valid - here's another link if it helps.
http://www.15seconds.com/issue/010220.htm
-
Oct 22, 2010, 13:36 #13
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I might make absolutely no sense here but I am going to ask it anyways:
Can I use a global.asa file with code like this:
Code:<script language="vbscript" runat="server"> sub Application_OnStart Application("Environment")="http://ip_address/root" end sub </script>
Is this possible? I am going to guess no as I cannot find my answer by searching...but I figured I'd ask here as I may not be using the right search terms.
Thanks!
-
Oct 23, 2010, 11:21 #14
- Join Date
- Jun 2007
- Posts
- 691
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Have you tried it ? Did it work ?
I doubt it will work.
If you're going to use Server.Execute anyway, why not use it as intended ?
-
Oct 24, 2010, 15:04 #15
- Join Date
- Oct 2001
- Location
- Vancouver BC Canada
- Posts
- 2,037
- Mentioned
- 5 Post(s)
- Tagged
- 0 Thread(s)
Ok, you've covered a lot of ground since you started this topic and it's splintered all over the place. I think I'll tackle include files first.
Include files - I always (out of habit) use relative paths (<!-- #include file="../inc/header.asp" -->) for my includes because it has been my experience that it makes my work more portable. I often use include files for global variables, paths, bolierplate code, object declarations etc....
Servers from Win2003 and up will throw a parent path disallowed error unless you go into your server control panel and allow it under one of the advanced menus. I haven't had to do that for a while but it's just a checkbox that needs to be selected and then reboot the server.
Server.Execute - This might be off topic but server.execute as become a very good friend of mine because it provides the ability to include and execute code according to the status of the program being executed as if it were part of the script that calls it. It's well worth the effort to learn if your going to do ASP classic coding for any period of time.
webber123456 included a great link to the 15 second site so give that a read. It explains server.execute quite nicely.
A common situation that I use server.execute is to include forms or display code in web admin sections. I can have a conditional statement that asks whether we're in edit or preview and depending on the answer I can set my action_variable = edit-form.asp or action_variable = preview.asp. Then in the body of the page I have Server.Execute(action_variable). All of the variable included in my action_variable regardless of whether it is a form or preview page are executed according to the code that preceded it.
I think the drawback to server.execute is that you can't server.execute some massive ASP library and pick the part that you want to use to suite the circumstances of your code. Instead, I just have small blocks of code that I use server.execute with and it really is a helpful way to keep complex ASP applications from becoming a maintenance nightmare.
Global ASA - Hopefully you can get your include working with relative (parent) paths and you don't need a global.asa but if I read your first post correctly global.asa does what you are trying to use your custom page config.asp.
You have two sections of the code to deal with the application and the session, so you would have to figure out whether the code your dealing with is for the application or the visitors session and apply your code accordingly. I have a hunch that you would be applying your code to the application but I could be wrong.
I stay away from global.asa myself because I in the past ran into troubles not understanding how it worked but if you need to assign global variable, objects, etc... then global.asa might be what you're looking for. There are some decent (old) ASP books that cover global.asa but this link might shed some light for you.
Here's another link
Good luck!
AndrewLast edited by awasson; Oct 24, 2010 at 15:06. Reason: clarification...
Andrew Wasson | www.lunadesign.org
Principal / Internet Development
-
Oct 25, 2010, 12:17 #16
- Join Date
- Oct 2010
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
wow thank you for the detail explanations! at this moment i am trying to persuade our server group to enable parent paths...so hopefully they will and this will be an easier solution than trying any of the suggested ones
i've already wasted a lot of time trying to work around this...
-
Oct 25, 2010, 12:29 #17
- Join Date
- Oct 2001
- Location
- Vancouver BC Canada
- Posts
- 2,037
- Mentioned
- 5 Post(s)
- Tagged
- 0 Thread(s)
No worries and yes, enabling parent paths is the best (easiest) way around the issue.
It's really easy to do once you know where it is in the server control snap-in. It's been a few years since I had to do it on my own servers so I don't recall the exact steps, otherwise I would have provided some more detail.
Cheers,
AndrewAndrew Wasson | www.lunadesign.org
Principal / Internet Development
-
Oct 26, 2010, 03:57 #18
- Join Date
- Sep 2010
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Visit the below link for more info on Server.Execute method:
http://www.bigresource.com/ASP-Serve...-q56dmupM.html
Bookmarks