我有一个例程“ BlahStat.aspx”在Azure网站上运行,该例程由远程服务(不受我们控制)调用,并将包含状态信息的文件写入本地目录。
<%@ Page Language="VB" explicit="true" validateRequest="false" %>
<%@ Import namespace="ADODB" %>
<%@ Import namespace="WinHttp" %>
<%@ Import namespace="MSXML" %>
<%@ Import namespace="Scripting" %>
<script language="VB" runat="Server">
Function CreateRandomGUID(ByRef tmpLength As Integer) As String
Randomize(Microsoft.VisualBasic.Timer())
Dim tmpCounter As Integer
Dim tmpGUID As String
Const strValid As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
For tmpCounter = 1 To tmpLength
tmpGUID = tmpGUID & Mid(strValid, Int(Rnd(1) * Len(strValid)) + 1, 1)
Next
tmpGUID = tmpGUID & Right(New String(Chr(48), 5) & CStr(Int(Rnd(1) * 100000)), 5)
CreateRandomGUID = tmpGUID
End Function
Dim MsgFilePath As String = "D:\home\site\mailroot\Drop"
Dim strstatus As String
Dim strid As String
Dim strMessageName As String
Dim dtCurrentDate As Date
Dim RecAddr As String
Dim SendAddr As String
Dim FileObject As Scripting.FileSystemObject
Dim OutputString As String
Dim MsgFile As Scripting.IFile
Dim strTempFile As String
Dim OutStream As Scripting.ITextStream
</script>
<%
strid = request.QueryString.Item("id")
strstatus = request.QueryString.Item("status")
If Len(strid) > 0 Then
dtCurrentDate = Today
strMessageName = "" & Hex(Year(dtCurrentDate)) & Hex(Month(dtCurrentDate)) & Hex(Microsoft.VisualBasic.Day(dtCurrentDate)) & CreateRandomGUID(13) & ""
If Len(strstatus) > 1 Then
SendAddr = "From: michael@bubble.com"
RecAddr = "To: *STATUS." & strid & "@blah.co.nz"
OutputString = SendAddr & Chr(13) & Chr(10) & RecAddr & Chr(13) & Chr(10) & Chr(13) & Chr(10) & strstatus & Chr(13) & Chr(10) & ""
FileObject = New Scripting.FileSystemObject
strTempFile = MsgFilePath & "\" & strMessageName & ".tmp"
OutStream = FileObject.CreateTextFile(strTempFile, True, False)
OutStream.WriteLine(OutputString)
OutStream.Close
OutStream = Nothing
MsgFile = FileObject.GetFile(strTempFile)
MsgFile.Name = "BLAH" & strMessageName & ".EML"
End If
End If
%>
此例程多年来一直在99.9%的时间中运行良好,但是,它一次又一次地莫名其妙地抛出500错误,如从http日志中捕获的一样
POST /BlahStat.aspx |128|800a0046|Permission_denied 443 - Apache-HttpClient/4.5.1+(Java/1.8.0_161) - blah.site.net 500
POST /BlahStat.aspx |134|800a0035|File_not_found 443 - Apache-HttpClient/4.5.1+(Java/1.8.0_131) - blah.site.net 500
POST /BlahStat.aspx |134|800a003a|File_already_exists 443 - Apache-HttpClient/4.5.1+(Java/1.8.0_131) -blah.site.net 500
实际上,自从输入重命名行以来已有几个月没有出现“ File_already_exists”了,这是因为下一个服务试图在写入完成之前尝试锁定和处理文件而添加的。砰! “ / Permission_denied”是最常用的,尽管现在实现了自定义错误页面,所有这些错误都不再记录,只需重定向即可。
我很高兴有各种各样的原因使这种例程轰炸Azure Web App上的文件写入(内存,中断等),因此是我的问题;
此.aspx代码是否有任何错误,以阻止其始终正常运行。.