1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Execute a file in ASP

Discussion in 'C#' started by filt, Aug 3, 2006.

  1. #1
    server.execute("file.asp")
    Code (markup):
    That executes the file file.asp.

    But how do i execute file.asp?count=10

    Anyone?
     
    filt, Aug 3, 2006 IP
  2. GULLIVER

    GULLIVER Well-Known Member

    Messages:
    668
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    110
    #2
    try
    strCount=10
    server.execute("file.asp")
    strCount=""

    in file.asp dont request("count")
    just write
    strCount

    Good Luck
     
    GULLIVER, Aug 3, 2006 IP
  3. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    gulliver, server.execute doesn't work quite that way. when server.execute executes an external page, it executes it as a stand-alone page with its own set of variables. local variables assigned on the "container" page don't affect the environment of the "executed" page. but your solution is VERY close.

    in fact, you can do this with one teensy modification to your suggested container page code: instead of
    FILT, you should try this instead:

    
    session("strCount")=10
    server.execute("file.asp")
    session("strCount")=""
    
    Code (markup):
    This will define a session variable, which you will find will be retrieved with no problems on the executed page. FILT, this code should work great for you. jsut remember that instead of referencing it via the request("count") method on file.asp, simply call the session variable session("strCount") in its place. should work fantastic.

    By the way, we're doing this sort of work-around because server.execute has difficulty with querystrings, in answer to your initial question on this thread.

    Hope this helps

    VG
     
    vectorgraphx, Aug 4, 2006 IP
  4. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #4
    Welcome back VG, haven't seen you for a while.

    Actually GULLIVER is my best friend and I was the one to suggest him to post it in ASP :)

    As always you know more than I, I have to try harder man :)
     
    ludwig, Aug 4, 2006 IP
  5. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks ludwig, i've been around - but i haven't posted that much lately. heck i haven't even updated my own blog in over a month :eek:

    As for my knowledge with server.execute, i really don't know all that much about it - other than i had a job a few years back where i needed to use it and ran into the EXACT situation that Filt is describing, where i was unsuccessfully trying to execute a page with a querystring. This (or something like this) was my solution then. Actually that's not entirely true, my solution then was probably alot less elegant :D

    I'm embarassed by the code i was writing 4 years ago hehe :p

    lataz

    VG
     
    vectorgraphx, Aug 4, 2006 IP
  6. Nafai

    Nafai Peon

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Or instead of EXECUTING the asp file you could just [!--#include it--]
     
    Nafai, Aug 7, 2006 IP
  7. filt

    filt Member

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #7

    Then i cant use a querystring...
     
    filt, Aug 8, 2006 IP
  8. Nafai

    Nafai Peon

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You can't use a querystring with Server.Execute either.

    That's why one of the posters above told you to store your querystring information in a variable, and then have the page you are executing access that variable.

    It would work the same way with an include, except the code would be included before runtime instead of during runtime, so it would probably be slightly faster.
     
    Nafai, Aug 8, 2006 IP