Parent ASP

  • Thread starter Karl E. Peterson
  • Start date
K

Karl E. Peterson

Hi Folks --

Old problem I'm considering revisiting. Say I have a bunch of "topics" and would
like each to share a common code base but be accessed through their own folders.
IOW, something like this:

http://domain.org/subfolder/topicX/
http://domain.org/subfolder/topicY/
http://domain.org/subfolder/topicZ/

The content can all be generated from a database and some ASP code. So, what I'd
really like to do is have an extremely simple index.asp in each folder that
determined it's own folder name ("topicX"), and used this as a key to pass to a
common code base to generates the rest of the content. Problem is, as my hazy
memory recalls, calling code in a parent directory (..\code) is considered a
potential security hazard, and IIS is set to prevent it. Is there a better design,
that doesn't involve replicating the code in each and every subfolder? (Am I making
any sense at all? <g>)

Thanks... Karl
 
M

Mike Mueller

Karl

You can use Request.ServerVariables("PATH_INFO ") to find out exactly where
you are at from the root.
--strThisPage= Request.ServerVariables("PATH_INFO ")

you could then parse the returned string and use an SQL call to get the info
from your db
--"SELECT pgTitle, pgBody FROM dbo.Pages WHERE (pgPath = '" & strThisPage &
"')"

and then you can use that info to fill in your page.I would probably make
this a function and use it in an include, to make the page lighterweight. I
use a similiar strategy in several sites that I work with- ending up with a
code working off of this logic:

-virtual include getpage

-virtual include header
<title><%=strTitle%></title>
-virtual include body
<%=strBody%>
-virtual include footer
and getpage has the routine to read your location, get the title and the
body
 
K

Karl E. Peterson

Hi Mike --

Yeah, that's the general idea. The problem seems to be if I need to use a ..\code
include page in there. (Working from memory here, as it's been a long time since I
looked at this.) IIS in 2003/2008 is set to automatically not allow that for fear
of some sort of exploit. Using your names, how do you avoid having to put
getpage/header/body/footer pages in each subfolder?

Thanks... Karl
 
M

Mike Mueller

<!--#include virtual="/includes/filename.ext"-->

and then I put all of the common code pages into the includes directory.
Include Virtual is relative to the site root.
 
K

Karl E. Peterson

Mike said:
<!--#include virtual="/includes/filename.ext"-->

and then I put all of the common code pages into the includes directory.
Include Virtual is relative to the site root.

Would it be relative to the root of a subweb on a test server? (I build on a
subweb, and publish to a "full-blown" web.) I thought not. That something like
that would still be looking at the server root.

Thanks... Karl
--
..NET: It's About Trust!
http://vfred.mvps.org


 
S

Stefan B Rusynko

No
- it always relative to the main root

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Mike Mueller wrote:
| > <!--#include virtual="/includes/filename.ext"-->
| >
| > and then I put all of the common code pages into the includes directory.
| > Include Virtual is relative to the site root.
|
| Would it be relative to the root of a subweb on a test server? (I build on a
| subweb, and publish to a "full-blown" web.) I thought not. That something like
| that would still be looking at the server root.
|
| Thanks... Karl
| --
| .NET: It's About Trust!
| http://vfred.mvps.org
|
|
|
| > | >> Hi Mike --
| >>
| >> Yeah, that's the general idea. The problem seems to be if I need to use a
| >> ..\code include page in there. (Working from memory here, as it's been a
| >> long time since I looked at this.) IIS in 2003/2008 is set to
| >> automatically not allow that for fear of some sort of exploit. Using your
| >> names, how do you avoid having to put getpage/header/body/footer pages in
| >> each subfolder?
| >>
| >> Thanks... Karl
| >>
| >>
| >> Mike Mueller wrote:
| >>> You can use Request.ServerVariables("PATH_INFO ") to find out exactly
| >>> where
| >>> you are at from the root.
| >>> --strThisPage= Request.ServerVariables("PATH_INFO ")
| >>>
| >>> you could then parse the returned string and use an SQL call to get the
| >>> info
| >>> from your db
| >>> --"SELECT pgTitle, pgBody FROM dbo.Pages WHERE (pgPath = '" & strThisPage
| >>> &
| >>> "')"
| >>>
| >>> and then you can use that info to fill in your page.I would probably make
| >>> this a function and use it in an include, to make the page lighterweight.
| >>> I
| >>> use a similiar strategy in several sites that I work with- ending up with
| >>> a
| >>> code working off of this logic:
| >>>
| >>> -virtual include getpage
| >>>
| >>> -virtual include header
| >>> <title><%=strTitle%></title>
| >>> -virtual include body
| >>> <%=strBody%>
| >>> -virtual include footer
| >>> and getpage has the routine to read your location, get the title and the
| >>> body
| >>>
| >>>
| >>>
| >>>
| >>>
| >>>
| >>>
| >>> | >>>> Hi Folks --
| >>>>
| >>>> Old problem I'm considering revisiting. Say I have a bunch of "topics"
| >>>> and would like each to share a common code base but be accessed through
| >>>> their own folders. IOW, something like this:
| >>>>
| >>>> http://domain.org/subfolder/topicX/
| >>>> http://domain.org/subfolder/topicY/
| >>>> http://domain.org/subfolder/topicZ/
| >>>>
| >>>> The content can all be generated from a database and some ASP code. So,
| >>>> what I'd really like to do is have an extremely simple index.asp in each
| >>>> folder that determined it's own folder name ("topicX"), and used this as
| >>>> a
| >>>> key to pass to a common code base to generates the rest of the content.
| >>>> Problem is, as my hazy memory recalls, calling code in a parent
| >>>> directory
| >>>> (..\code) is considered a potential security hazard, and IIS is set to
| >>>> prevent it. Is there a better design, that doesn't involve replicating
| >>>> the code in each and every subfolder? (Am I making any sense at all?
| >>>> <g>)
| >>>>
| >>>> Thanks... Karl
| >>>> --
| >>>> .NET: It's About Trust!
| >>>> http://vfred.mvps.org
| >>
| >> --
| >> .NET: It's About Trust!
| >> http://vfred.mvps.org
|
|
|
 
K

Karl E. Peterson

Stefan said:
No
- it always relative to the main root

Yeah, that's the issue. Can't use the same code on the test subweb and deployed
web. :-/
 
M

Mike Mueller

Are these 2 different sites on the same server? You can set-up a server to
share folders between multiple webs.
 
K

Karl E. Peterson

Mike said:
Are these 2 different sites on the same server?

No, I have an in-house (w2k3) server that I test webs on. On there, they exist as
subwebs. I suppose, I really ought to convert them over to real webs (not sure I
can do that, without invoking the good graces of the IT dept?), but originally it
was just IIS running on an NT4 workstation and things just sort of evolved.
 
K

Karl E. Peterson

Pat said:
Just in case you want to enable Parent Pathing, follow this KB.
http://support.microsoft.com/kb/276548/)

Thanks. Yeah, that's the fallback. I'm told by the box owner he'd "rather I
didn't", so I've been looking for a more elegant design that would allow me to avoid
that. I have a feeling I may end up going ahead and doing that, though.
 

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

Top