找到ASP错误的原因

时间:2016-11-18 08:09:42

标签: iis asp-classic

我的经典ASP网站上有一些简单的代码,当页面出错时向我发送电子邮件,因为我在web.config中设置了这个以指向页面来处理错误:

<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
    <remove statusCode="500" subStatusCode="100" />
    <remove statusCode="500" subStatusCode="-1" />
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" path="/error_404.asp" responseMode="ExecuteURL" />
    <error statusCode="500" prefixLanguageFilePath="" path="/error_500.asp" responseMode="ExecuteURL" />
    <error statusCode="500" subStatusCode="100" path="/error_500.asp" responseMode="ExecuteURL" />
</httpErrors>

这是我的一小段代码:

...
set objError =          Server.getLastError()
strNumber =             objError.AspCode
strSource =             objError.Category
strDesc =               newstr(objError.Description)
strCode =               newstr(objError.Source)
strLine =               ObjError.Line
strASPDesc =            ObjError.ASPDescription
strRemoteAddr =         Request.ServerVariables("REMOTE_ADDR")
ref =                   request.servervariables("HTTP_REFERER")
str =                   request.servervariables("QUERY_STRING")
cookies =               request.servervariables("HTTP_COOKIE")
ip_url =                strRemoteAddr
ua =                    newstr(request.servervariables("HTTP_USER_AGENT"))
totalstring =           objError.File & "?" & str

然后我将这些值连接在一起并通过电子邮件将详细信息发送给自己。

对于错误,我会得到类似的结果:

strNumber: ASP 0126
strSource: Active Server Pages
strDesc: Include file not found
strCode:
strLine: 14
strASPDesc: The include file '/news/aw.asp' was not found.
strRemoteAddr: 2.101.166.175
ref: http://example.com/sites/support/
str: page=cd
cookies: usr1=62105233D8E2A062A55; fantastic%5Fcheese=1; _ga=GA1.3.1357551757.1476543431; __atuvc=2%7C41%2C1%7C42%2C0%7C43%2C0%7C44%2C9%7C45; __utma=154830755.1357551757.1476543431.1476822981.1479368067.3; __utmz=154830755.1476818175.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ASPSESSIONIDQCBABQAR=KHGBAMBCCCENHCIPPCOFBJOO; __utmb=154830755.1.10.1479368067; __utmc=154830755; __utmt=1
ip_url: 84.92.46.118
ua: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
totalstring: /sites/support/page.asp?landscape=cd

但是,我经常只看到这个错误:

strNumber:
strSource:
strDesc:
strCode:
strLine: 0
strASPDesc:
strRemoteAddr: 43.247.156.6
ref: http:/example.com/content/this.asp
str: 500;http://jimpix.co.uk:80/words/check-username.asp
cookies: ASPSESSIONIDSAABARBQ=ACDDOHOCEKIEFOCKFBFIHJBC; _gat=1; __atuvc=129%7C46; __atuvs=582e898682f62926059; _ga=GA1.3.491207786.1479439414
ip_url: 43.247.156.6
ua: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
totalstring: ?500;http:/example.com:80/content/this.asp

此处没有错误详细信息,但它始终位于同一页面上。我无法解决导致它的原因。

我可以做更详细的错误记录以了解更多信息吗?

1 个答案:

答案 0 :(得分:0)

Server.getLastError()仅在响应缓冲区开始向客户端刷新内容之前保持填充状态,原因可能是:

  1. response.buffer设置为false
  2. response.flush被称为
  3. response.end被称为
  4. 文档中提到了这一点:

      

    This method is available only before the .asp file has sent any content to the client.

    这是我能想到的唯一可以解释为什么你的Server.getLastError()似乎是空白的。