質問

ってカスタムエラー自分のサーバーさんに残念にページを下図のように

<customErrors mode="On"> 
   <error statusCode="500" redirect="/servererror/default.aspx" /> 
</customErrors>

応させていただくことが、ページ servererror/default.aspx いで送信するe-mailへの exception.message

こちらはどのようにしているものでな

Sub Page_load(ByVal sender As Object, ByVal e As EventArgs)

     Dim LastError As Exception
     Dim ErrMessage As String

     LastError = Server.GetLastError()


        ErrMessage = LastError.Message


Dim Errormail = New MailMessage

     'Send email to me
     Errormail.To           = "email@email.co.uk"

     Errormail.From         = "servererror@email.co.uk"
     Errormail.Subject      = "Server Error Alert"
     Errormail.BodyFormat   = MailFormat.Text
     Errormail.Priority     = MailPriority.Normal
     Errormail.Body         = ErrMessage

     SmtpMail.SmtpServer    = "localhost"

     SmtpMail.Send(Errormail)

     Server.ClearError()
End Sub

助けしますが、ご協力をお願いし

感謝

Jamie

役に立ちましたか?

解決

はこちらを参照してください:ASP.NET カスタムエラーページ-サーバーです。GetLastError()がnullの場合

を追加する必要がありますのredirectmode:

<customErrors mode="On" redirectMode="ResponseRewrite"> 
   <error statusCode="500" redirect="/servererror/default.aspx" /> 
</customErrors>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top