File System Object and displaying data

Discussion in 'ASP General' started by Rahul Chatterjee, Nov 2, 2006.

  1. Hello All

    I used to have some static htm files which used to display data. There is a
    calling asp file which used to do something like below

    if Request.QueryString("PageName").count = 0 then
    strPageNameHtm = "toc.htm"
    strPageNameInc = "toc.inc"
    else
    strPageNameHtm = Request.QueryString("PageName") & ".htm"
    strPageNameInc = Request.QueryString("PageName") & ".inc"
    end if
    strPageNameHtm = server.mapPath(strPageNameHtm)

    strPageNameInc = server.mapPath(strPageNameInc)
    'response.write(strPageNameHtm)
    set fs = server.createobject("scripting.fileSystemObject")
    set f = fs.openTextFile(strPageNameHtm)
    strSPDHtml = f.readall


    The strSPDHTML info used to be displayed using a response.write(strSPDHTML).
    This allowed the static content to be loaded up.

    I switched the static pages to be asp pages having the content come from a
    database. I would still like to maintain the controlling page logic. Can I
    modify the above section of code in anyways to access the asp page content
    Rahul Chatterjee, Nov 2, 2006
    #1
    1. Advertising

  2. "Rahul Chatterjee" <> wrote in message
    news:OOBjhir$...
    > Hello All
    >
    > I used to have some static htm files which used to display data. There is

    a
    > calling asp file which used to do something like below
    >
    > if Request.QueryString("PageName").count = 0 then
    > strPageNameHtm = "toc.htm"
    > strPageNameInc = "toc.inc"
    > else
    > strPageNameHtm = Request.QueryString("PageName") & ".htm"
    > strPageNameInc = Request.QueryString("PageName") & ".inc"
    > end if
    > strPageNameHtm = server.mapPath(strPageNameHtm)
    >
    > strPageNameInc = server.mapPath(strPageNameInc)
    > 'response.write(strPageNameHtm)
    > set fs = server.createobject("scripting.fileSystemObject")
    > set f = fs.openTextFile(strPageNameHtm)
    > strSPDHtml = f.readall
    >
    >
    > The strSPDHTML info used to be displayed using a

    response.write(strSPDHTML).
    > This allowed the static content to be loaded up.
    >
    > I switched the static pages to be asp pages having the content come from a
    > database. I would still like to maintain the controlling page logic. Can

    I
    > modify the above section of code in anyways to access the asp page content
    >


    Sounds like you are looking for this:-

    if Request.QueryString("PageName").count = 0 then
    strPageName = "toc.asp"
    else
    strPageName = Request.QueryString("PageName") & ".asp"
    end if
    Server.Execute strPageName
    end if

    You should be aware however that this can allow a client to bypass some
    forms of security. E.g a sub folder of ASPs may have anonymous user turned
    off or IP range restrictions but the above page could allow an external user
    to execute these pages.
    Anthony Jones, Nov 7, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kathy Burke
    Replies:
    2
    Views:
    5,119
    Kevin Spencer
    Aug 1, 2003
  2. Showjumper
    Replies:
    2
    Views:
    1,789
    Showjumper
    Aug 2, 2003
  3. .Net Sports

    datagrid not displaying data table data

    .Net Sports, Aug 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,762
    .Net Sports
    Aug 31, 2005
  4. Andy B
    Replies:
    2
    Views:
    3,132
    Andy B
    Apr 23, 2008
  5. Albert
    Replies:
    4
    Views:
    10,833
    Albert
    Jul 10, 2008
Loading...

Share This Page