ASP.Net/Development/Diagnose Error — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 11:51, 26 мая 2010
Diagnose error Demo
<%@ Import Namespace="System.Diagnostics" %>
<script language="VB" runat="server" >
Sub EntrytoLog()
dim intCounter as integer
intCounter =1
for intCounter=1 to 10
intCounter = intCounter+1
next
response.write ("The value of the counter is:" & intCounter & "<br>")
intCounter = "Storing a string to an integer"
End sub
Sub Page_Error(sender As Object, exc As EventArgs)
dim errorMessage as string
errorMessage = "Error occurred" & Server.GetLastError().ToString()
Server.ClearError()
Dim LogName As String = "MyApplicationLog"
Dim SourceName As String = "MyApplicationSource"
If (Not EventLog.SourceExists(SourceName))
EventLog.CreateEventSource(SourceName, LogName)
End If
"Insert into Event Log
Dim MyLog As New EventLog
MyLog.Source = LogName
MyLog.WriteEntry(errorMessage, EventLogEntryType.Error)
End Sub
</script>
<%
EntrytoLog()
%>
Page level error
<script language="VB" runat="server">
Sub PageLevelErrorTest()
Dim intCounter as integer
intCounter =1
For intCounter=1 To 10
intCounter = intCounter+1
Next
Response.Write ("The value of the counter is:" & intCounter & "<br>")
intCounter = "Storing a string to an integer"
End Sub
Sub Page_Error(sender As Object, exc As EventArgs)
Response.Write("Error occurred: " & Server.GetLastError().ToString())
Server.ClearError()
End Sub
Sub Page_Load()
PageLevelErrorTest()
End Sub
</script>