Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic ASP - Request object Is Empty

I'm working on adding a feature to an old classic asp site and ran into an interesting problem. The following line on the page results in the helpful error "Object required:'' "

strServerName = Request.ServerVariables("server_name")

When I attached a debugger to look at it, Request is in fact Empty, which I don't understand how that can happen? This line exists on several pages and executes with no problems besides this one. In this case, the page is executed by a Redirect from another page.

I've been searching for a solution for a day or so now and haven't been able to locate anything that's been helpful. I'm desperate, any ideas would be greatly appreciated.

Oh, and if any more information is required, please don't hesitate to call me out.

Thanks!

Update 1
As requested, below is the entire code snippet wrapped in <% %> tags. This block exists as first code within the file (named 'order-results-instant.asp'):

<%
strServerName = Request.ServerVariables("server_name")
strServerName = UCase(strServerName)

strServerURL = "http://localhost/cbr"
strServerURLhttps = "https://localhost/cbr"
strConnect = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=CBR; Integrated Security=SSPI"

Dim objConn
Dim sql_stmt
Dim rs  
%>

Update 2
I've used the following 2 methods to redirect execution to this page - perhaps this can cause the request to be lost?

 'Response.Redirect strServerURL & "/order-results-instant.asp?gwstep=1"
 Response.Write "<META HTTP-EQUIV=""refresh"" content=""5;URL=" & strServerURL & "/order-results-instant.asp?gwstep=1"">"
like image 882
Matt Klinker Avatar asked May 19 '09 16:05

Matt Klinker


4 Answers

Scan through the rest of the code. At the Global level you will find this:-

Dim Request

Rename this variable and its current usage and the Request object attached to the script context will become visible.

like image 128
AnthonyWJones Avatar answered Nov 15 '22 03:11

AnthonyWJones


On your server is the Active Server Pages Web Service extension allowed (turned on) ?

like image 1
Mcbeev Avatar answered Nov 15 '22 03:11

Mcbeev


I copied your code into my test asp file with the following code and it redirected just fine.

<%
strServerName = Request.ServerVariables("server_name")
strServerName = UCase(strServerName)
strServerURL = "http://localhost/"
strServerURLhttps = "https://localhost/"
strConnect = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=CBR; Integrated Security=SSPI"
Dim objConn
Dim sql_stmt
Dim rs  

Response.Write(strServerName)

if Request.Querystring("test") <> "1" then
    Response.Redirect("http://" + strServerName + "/asptest.asp?test=1")
 end if
%>

The only real difference is I am adding "http://" to the redirect. Maybe something I did will shed some light to help you solve your issue.

thanks

like image 1
CodeLikeBeaker Avatar answered Nov 15 '22 04:11

CodeLikeBeaker


Does it work if you try to access it at an earlier point in the page?

like image 1
joth Avatar answered Nov 15 '22 03:11

joth