经典ASP - 请求对象为空

时间:2021-01-12 01:45:26

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:'' "

我正在努力为旧的经典asp网站添加一个功能,并遇到了一个有趣的问题。页面上的以下行导致有用的错误“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'):

更新1根据要求,下面是包含在<%%>标记中的整个代码段。该块作为文件中的第一个代码存在(名为'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?

更新2我使用了以下两种方法将执行重定向到此页面 - 这可能会导致请求丢失?

 '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"">"

4 个解决方案

#1


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.

重命名此变量及其当前用法和附加到脚本上下文的Request对象将变为可见。

#2


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

在您的服务器上是否允许(打开)Active Server Pages Web服务扩展?

#3


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

我使用以下代码将您的代码复制到我的测试asp文件中,并且重定向很好。

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

唯一真正的区别是我在重定向中添加了“http://”。也许我所做的事情会帮助你解决问题。

thanks

#4


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

如果您尝试在页面中的较早位置访问它,它是否有效?

#1


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.

重命名此变量及其当前用法和附加到脚本上下文的Request对象将变为可见。

#2


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

在您的服务器上是否允许(打开)Active Server Pages Web服务扩展?

#3


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

我使用以下代码将您的代码复制到我的测试asp文件中,并且重定向很好。

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

唯一真正的区别是我在重定向中添加了“http://”。也许我所做的事情会帮助你解决问题。

thanks

#4


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

如果您尝试在页面中的较早位置访问它,它是否有效?