2017-06-14 101 views
1

我的主要目标:为应用程序添加错误处理程序通用页面。经典ASP中的自定义错误处理

我的应用程序使用Application Pool .Net v 4.5 Classic运行于经典ASP和ASP.net。使用的customErrors,我可以使用来处理.NET网页错误:

<customErrors allowNestedErrors="true" defaultRedirect="~/ErrorPage.aspx" mode="On"> 
<error statusCode="404" redirect="~/ErrorPage.aspx?msg=404" /> 
<error statusCode="500" redirect="~/ErrorPage.aspx?msg=500" /> 
</customErrors> 

使用下面的链接,我想添加自定义错误处理程序,ASP页面 https://msdn.microsoft.com/en-gb/library/ms524942.aspx

https://msdn.microsoft.com/en-us/library/ms525983(v=vs.90).aspx

我主要目标是处理VbScript运行时/语法错误500.100,所以我已更新 Web.config中的HttpErrors节点为:

<httpErrors errorMode="Custom"> 
     <error statusCode="500" subStatusCode="100" path="~/frmErrorPage.asp" responseMode="Redirect" /> 
</httpErrors> 

我在应用程序的根文件夹中有ASP错误处理页面:frmErrorPage.asp。 代码:

<%@ Language=VBScript %> 
<% Option Explicit %> 
<% Response.CacheControl = "no-cache" %> 
<% Response.AddHeader "Pragma", "no-cache" %> 
<% Response.Expires = -1 %> 

<% ' VI 6.0 Scripting Object Model Enabled %> 
<!--#include file="_ScriptLibrary/pm.asp"--> 
<script ID="serverEventHandlersVBS" LANGUAGE="vbscript" RUNAT="Server"> 

dim objASPError 

Sub thisPage_onenter() 

ShowErrorInformation() 

end sub 

Function ShowErrorInformation() 
On Error Resume Next 
Set objASPError = Server.GetLastError 
Response.Write Server.HTMLEncode(objASPError.Category) 
If Len(CStr(objASPError.ASPCode)) > 0 Then 
    Response.Write Server.HTMLEncode(", " & objASPError.ASPCode) 
End If 
Response.Write Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")") & "<br>" 
If Len(CStr(objASPError.ASPDescription)) > 0 Then 
    Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "<br>" 
ElseIf Len(CStr(objASPError.Description)) > 0 Then 
    Response.Write Server.HTMLEncode(objASPError.Description) & "<br>" 
End If 
end function 

</script> 

<HTML> 
<HEAD> 
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> 
<TITLE></TITLE> 

<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/THEME.CSS" VI6.0THEME="Expedition"> 
<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/GRAPH0.CSS" VI6.0THEME="Expedition"> 
<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/COLOR0.CSS" VI6.0THEME="Expedition"> 
<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/CUSTOM.CSS" VI6.0THEME="Expedition"> 

</HEAD> 
<BODY onload="return window_onload()"> 

</BODY> 
</HTML> 

这不是为我工作,我已经尝试过其他的变化,但没有成功yet.Help?

+0

移动错误恢复在显示选项后显示在页面顶部 – mjw

回答

0

在ASP Classic中创建自己的方法/函数,并通过所需的参数与行号,页面名称,错误描述与发送错误电子邮件通知您是在PROD Evn中工作。

对于实施例 呼叫的HandleError(strScreenName,strScriptName,strFunctionName,Err.Number的,err.Description, “”)

功能的HandleError 集objASPError = Server.GetLastError
“创建自己的逻辑 端功能