Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Server.Excute - Dynamic URL

Question posted by: Jez (Guest) on July 24th, 2008 06:45 PM
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
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
=?Utf-8?B?T2xkIFBlZGFudA==?='s Avatar
=?Utf-8?B?T2xkIFBlZGFudA==?=
Guest
n/a Posts
July 24th, 2008
07:55 PM
#2

Re: Server.Excute - Dynamic URL
filename = "file.asp?id=" & ID
Quote:
Originally Posted by
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/lib...849(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).



 
Not the answer you were looking for? Post your question . . .
182,317 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors