Server.Excute - Dynamic URL

J

Jez

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
 
O

Old Pedant

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).
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top