Server.Excute - Dynamic URL

Discussion in 'ASP General' started by Jez, Jul 24, 2008.

  1. Jez

    Jez Guest

    Can anyone help me with this ??
    ASP on Windows 2003

    filename = "file.asp?id=" & ID
    Server.Execute("filename")

    This doesn't work... Any ideas ?

    Thanks
    Jez, Jul 24, 2008
    #1
    1. Advertising

  2. Jez

    Old Pedant Guest

    > filename = "file.asp?id=" & ID
    > Server.Execute("filename")
    >
    > This doesn't work... Any ideas ?


    Well, first of all, because you used
    Server.Execute("filename")
    you are asking to execute an asp page named
    filename

    When you put quotes around ANYTHING, you make it into a *STRING*. And then
    the value of the string *IS* the stuff inside the quotes.

    What you probably *MEANT* to do was
    filename = "file.asp?id=" & ID
    Server.Execute filename ' NO QUOTES! And the parentheses are optional

    BUT...

    But that still won't work.

    Read the docs:

    http://msdn.microsoft.com/en-us/library/ms525849(VS.85).aspx

    I quote from the "Parameters" section of that page:

    "Path
    A string specifying the location of the .asp file to execute. The Path
    parameter may be for either an absolute or a relative path. If Path is
    absolute, it must map to an ASP script in the same application as the calling
    ..asp file. Path can be a string variable name that is set at run-time. The
    Path parameter must not contain a query string, or IIS returns an error."

    One more time:

    "The Path parameter must not contain a query string, or IIS returns an error."

    'nuff said?

    The only good way to send info from the root page to the one requested via
    Server.Execute is via a session variable.

    Maybe something like this:
    Session("ExecuteID") = ID
    Server.Execute "file.asp"

    And then your "file.asp" page would need to know to get the ID via
    ID = Session("ExecuteID")

    I should note that Server.Execute is enormously inefficient. It's fine for
    lightly loaded sites and/or pages, but it's not a good idea on heavily used
    pages (say those hit more than 2000 times per hour? just as a rule of thumb).
    Old Pedant, Jul 24, 2008
    #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. Yoshitha

    how to excute exe

    Yoshitha, Jun 28, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    1,898
    Eliyahu Goldin
    Jun 28, 2005
  2. HS1
    Replies:
    3
    Views:
    926
    Gerbrand van Dieijen
    Nov 17, 2004
  3. HAK
    Replies:
    0
    Views:
    335
  4. news
    Replies:
    1
    Views:
    347
    Ivan Vecerina
    Nov 25, 2003
  5. mory2311

    excute command

    mory2311, Nov 4, 2006, in forum: Java
    Replies:
    3
    Views:
    343
    Jim Korman
    Nov 5, 2006
Loading...

Share This Page