经典 ASP - 奇怪的类型不匹配错误
Classic ASP - Strange Type Mismatch error
下面是模拟问题的示例代码:
functs.asp
<%
Function SecureStr(Str)
Dim Res
Res = Trim(Str)
If (Res <> "") Then
Res = Replace(Res, "'", "")
Res = Replace(Res, ";", "")
Res = Replace(Res, "=", "")
End If
SecureStr = Res
End Function
%>
main.asp
<%
Option Explicit
Dim Dept
Dept = Request.QueryString("d")
%>
<html>
<body>
<%=Server.Execute(Dept & ".asp")%>
</body>
</html>
buy.asp
<!--#include file="functs.asp"-->
<%
Dim Name
Name = SecureStr(Request.Form("name"))
%>
BUY CONTENT
如您所见,functs.asp 包含在 buy.asp 文件中。这样它在打开 http://localhost/main.asp?d=buy 时没有问题(错误)。但是现在我试图在 main.asp 中包含 functs.asp,像这样:
main.asp
<%
Option Explicit
Dim Dept
Dept = Request.QueryString("d")
%>
<!--#include file="functs.asp"-->
<html>
<body>
<%=Server.Execute(Dept & ".asp")%>
</body>
</html>
buy.asp
<%
Dim Name
Name = SecureStr(Request.Form("name"))
%>
BUY CONTENT
好吧,当 functs.asp 包含在 main.asp 中时,我收到一条错误消息:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'SecureStr'
/buy.asp, line 3
拜托,有人可以帮助我吗?真不知道怎么回事...
谢谢!
这并不奇怪,但实际上是 Server.Execute 的预期行为。
来自 Remarks 部分:
If a file is included in the calling page by using #include, the
executed .asp will not use it. For example, you may have a subroutine
in a file that is included in your calling page, but the executed .asp
will not recognize the subroutine name. You must include the file in
each executed .asp that requires the subroutine.
下面是模拟问题的示例代码:
functs.asp
<%
Function SecureStr(Str)
Dim Res
Res = Trim(Str)
If (Res <> "") Then
Res = Replace(Res, "'", "")
Res = Replace(Res, ";", "")
Res = Replace(Res, "=", "")
End If
SecureStr = Res
End Function
%>
main.asp
<%
Option Explicit
Dim Dept
Dept = Request.QueryString("d")
%>
<html>
<body>
<%=Server.Execute(Dept & ".asp")%>
</body>
</html>
buy.asp
<!--#include file="functs.asp"-->
<%
Dim Name
Name = SecureStr(Request.Form("name"))
%>
BUY CONTENT
如您所见,functs.asp 包含在 buy.asp 文件中。这样它在打开 http://localhost/main.asp?d=buy 时没有问题(错误)。但是现在我试图在 main.asp 中包含 functs.asp,像这样:
main.asp
<%
Option Explicit
Dim Dept
Dept = Request.QueryString("d")
%>
<!--#include file="functs.asp"-->
<html>
<body>
<%=Server.Execute(Dept & ".asp")%>
</body>
</html>
buy.asp
<%
Dim Name
Name = SecureStr(Request.Form("name"))
%>
BUY CONTENT
好吧,当 functs.asp 包含在 main.asp 中时,我收到一条错误消息:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'SecureStr'
/buy.asp, line 3
拜托,有人可以帮助我吗?真不知道怎么回事...
谢谢!
这并不奇怪,但实际上是 Server.Execute 的预期行为。
来自 Remarks 部分:
If a file is included in the calling page by using #include, the executed .asp will not use it. For example, you may have a subroutine in a file that is included in your calling page, but the executed .asp will not recognize the subroutine name. You must include the file in each executed .asp that requires the subroutine.