Avatar of opacons
opacons asked on

Classic ASP, Server.Execute failed while loading error

I'm trying to use a session variable together with a string literal as an argument to the Server.Execute function. When it is called I get a "Server.Execute failed while loading" error.

The code looks like this:
<%
Dim f
f = Session("site_root") & "/inc/incfile.asp"
Server.Execute(f)
%>

Session("site_root") returns a path similar to "/localhost/website" so based on the example above f = "locahost/website/inc/incfile.asp".

I don't want to use an SSI because of differences between the testing and production environments.

In essence all I want to do is have a variable webroot which can be adjusted according to the server setup the site is being run on.
Web Languages and StandardsASPWeb Development

Avatar of undefined
Last Comment
dosth

8/22/2022 - Mon
dosth

seems session is null

can you hardcode like this and test to trap

Session("site_root") = server.mappath(".")

Badotz

Chances are there is an error in our included page. Try Response.Redirect instead, and see what happens. Once debugged, then you can switch back to Server.Execute...
ASKER
opacons

I've checked the debugger and Session("site_root") is not null.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
opacons

There are no errors in the included page.
Badotz

f = Session("site_root") & "/inc/incfile.asp"

What, pray tell, is the value of <f>?
Badotz

The *actual* value, not what you think it is (or expect it to be).
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
dosth

hardcode f = "locahost/website/inc/incfile.asp"

<%
Dim f
f = "locahost/website/inc/incfile.asp"
Server.Execute(f)
%>

tell me this works fine?
Badotz

>>tell me this works fine?

Are you saying this works, or are you asking if this will work?
dosth

i am asking you to hardcode and try
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
opacons

In researching this problem, I've come across a post claiming that Server.Execute doesn't work with IIS virtual websites. I haven't tested this yet. Can anyone confirm this?
Badotz

>>i am asking you to hardcode and try

Me? Why don't you try it?
ASKER
opacons

FYI, dosth's hardcode suggestion doesn't make any difference.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
dosth

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Badotz

And where, pray tell, do you use the <MapPath> method? I sure don't see it...

Oh, and that error message is a Pretty Good Clue for you...
dosth

thanks