????? ????? ??????? ?? ASP.NET ???????? Visual Basic .NET ????? ??? ?????

?????? ????????? ?????? ?????????
???? ???????: 308132 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ??????? ????????? ???????? Visual Basic .NET ?????? ?????????? ??? ????? ??? ?????? ?? ASP.NET. ????? ASP.NET ??? ?????? ??? ?????? ???????? ?? ????????? Microsoft ????? ?????? ?????? (ASP). ?? ASP.NET ? ????? ?????? ??????? ?? ??? ??????? ?????? ?? ?????????.


??????? ??????? ?? ASP.NET

???? ASP.NET ?????? ?? ???????? ?? ??? ????? ?????? ?? ????????? ??? ?????. ?? ASP ????????? ?????? ????? "??? ??? ??????? ??????" (?? ??? ???? ???????? ?? JScript). ???? ????? ??? ??? ???? ?????? "????? ??????? ???????? ?? Microsoft" (IIS) 5.0 ??????? ?????? ASPError ?????? ???? ??? ????? ??????. ??? ???? ????? ??? ????? ?????? ?????? ???.

???? ASP.NET ??? ??????? ???? ????? ?????? ?? ????????? ??? ??????? ???? ?? ???? ??? ????? ??? ??????? ASP.NET. ???? ASP.NET ????? ?????? ??????? ???? ???? ?????? ?????????? ??? ????? ??? ??????: ????? Page_Error ????? Application_Error ?????? ??????? ????? (Web.config).

???? ??? ??????? ????? ??????? ??? ??????? ??????? ?? ????? ASP.NET. ??? ????? ?? ?? ???? ??? ??????? ????? ????? ????? ??? ????? ??????? ?? ??????? ?????? ????? ????? ?????? ??? ASP.NET ? ?? ???? ??? ?????? ?????? ????? ??? ???? ???????? - catch-??????? ????? ??????? ??? ????? ????? ?????? (CLR) ??????? ??????.


????? ??????? ??? Page_Error

???? ????? Page_Error ????? ??? ?????? ??????? ???? ???? ????? ??????. ????? ??? ??????? ????? ?????? (??? ???? ????? ???????? ???????? ???????) ? ?? ????? ????? ????? ?? ????? ????? ???.

??????: ???? ??? ?????? ??????? ????? ??????? ?? ???????? ??? ?????? ????? ????????. ?????? ??? ???? ????? ??? ??? ??????? ????? ??? ???????? ??????? ???????? ???? ??? ????? ??????? ??? ????????. ????? ????? ????? ???? ???? ????? ??? ???????? ??????? ??? ??? ??? ?? ????? ?????? ????? ??????? ?????? ?? ??? ???????.

???? ??? ?????? ??????? ????? ???? ??? ?? ????? Page_Load. ???? ??????? ??????? ?????? ?????? ??????? ???? ???? ?????? ????? Page_Error.
  1. ???? ??????? ??????? ?????? ??? ???? ???? PageEvent.aspx ??? ???????:
    1. ???? Microsoft Visual Studio .NET.
    2. ?? "?????? ??????" ???? ??? ?????? ?????? ??? ???? ??????? ??? ??? ????? ?? ?? ???? ??? ????? ????? ???.
    3. ?? ???? ???? ??? ???? PageEvent.aspx ??? ?? ???? ??? ???.
  2. ?? ?????? ????????? ???????? ??????? ??? ????? ?????? PageEvent.aspx:
    <%@ Page Language="vb"%>
    <script runat=server>
    Sub Page_Load(Sender as object, e as EventArgs)
    	throw(new System.ArgumentNullException())
    End Sub
    		
    Sub Page_Error(Sender as object, e as EventArgs)
    	Dim objErr as Exception = Server.GetLastError().GetBaseException()
    	Dim err as String = "<b>Error Caught in Page_Error event</b><hr><br>" & _ 
    			  "<br><b>Error in: </b>" & Request.Url.ToString() & _
    			  "<br><b>Error Message: </b>" & objErr.Message.ToString() & _
    			  "<br><b>Stack Trace:</b><br>" & _
    			  objErr.StackTrace.ToString()
    	Response.Write(err.ToString())
    	Server.ClearError()
    End Sub
    </script>
    
    					
  3. ?? ??????? ???? ???? ??? ??? PageEvent.aspx.
  4. ???? ??? ?????? ?????? ??? ?????? ?? ???? ??? ??? ?? ?????? ?????? ??????. ???? ?? ????? ??? ?????? ????? ???????? ??? ??????? ????????? ????????.
??????: ????? ?? ????? ?? ???????? ???????? ?????? ??????? Server.ClearError. ???? ??? ????? ?? ???????? ??? ?????? ????? Application_Error.


????? ??????? ??? Application_Error

???? ??????? Page_Error ????? ??????? ????? Application_Error ??? ?????? ??????? ???? ???? ?? ??????? ????? ??. ????? ????? ??????? ???? ??????? ???? ????? ??????? ????? ??????? ?? ?????? ??????? ????? ????????? ?????? ???? ?? ????.

????? ??????? ???????? ??? ????? ????????? ???????? ????? Page_Error ?????? ?? ???? ?????? ??? ?? ?? trapped ????? ?? ????? Page_Load ?? ????? Page_Error. ??? ????? ????? Application_Error ?? ??? Global.asax ??????? ????? ??. ??????, ??????? ?? ??? ?????? ?????? ???? ????? ?? ??? ????????? ?????? ????? ?? ????? Application_Error ??? Global.asax ?? ????? ????? ??? ??? ???????. ???? ??????? ??????? ????? ??????? ????? Application_Error:
  1. ????? ??? ???? ???? AppEvent.aspx ??? ???????.
  2. ?? ?????? ????????? ???????? ??????? ??? AppEvent.aspx:
    <script language=vb runat="server">
         Sub Page_Load(Sender as object, e as EventArgs)
    	     throw(new ArgumentNullException())
         End Sub
    </script>
    					
  3. ?? ??????? ???? ???? ??? ??? AppEvent.aspx.
  4. ????? ??? Application_Error ??? ??? Global.asax ??? ?????? ??? ??????? ?? ????? Page_Load ?????? AppEvent.aspx. ???? ??? ??? ????? ????? ?????? ????????? ?????? ????? System.Diagnostics Global.asax ???????? ??? ???????.

    ?? ?????? ????????? ???????? ??????? ??? objErr ????? Application_Error(ByVal sender As Object, ByVal e As EventArgs) Sub System.Diagnostics file:
    Imports System.Diagnostics
    
            Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
            Dim objErr As Exception = Server.GetLastError().GetBaseException()
            Dim err As String = "Error Caught in Application_Error event" & _
                                System.Environment.NewLine & _
                                "Error in: " & Request.Url.ToString() & _
                                System.Environment.NewLine & _
                                "Error Message: " & objErr.Message.ToString() & _
                                System.Environment.NewLine & _
                                "Stack Trace:" & objErr.StackTrace.ToString()
    
            EventLog.WriteEntry("Sample_WebApp", err, EventLogEntryType.Error)
            Server.ClearError()
            'additional actions...
        End Sub
    					
  5. ??? ????? Global.asax.
  6. ?? Visual Studio .NET ? ?? ??????? ????? ? ???? ??? ?????.
  7. ???? ??? ?????? ?????? ??? ?????? ?? ???? ??? ??? ?? ??????. ?? ??? ?????? ???? ?????? ?????, ??? ????? ?? ???? ??? ?? ????? ????? ????? ???? ?? ??? ???????. ???? ??? ??????? ????? ?? ??? ??????? ???? ???? ?????? ????? ?? "???? ???????". ??? ????? ????? ?? ????? ??? ????? ????? ???????? ??? ???? ??? ??????? ??????? ???????? ?????? ???? ???? ?? ???? ??? ????????? ?????? ??? ??????.

????? ??????? ??? Web.config

??? ??? ??????? Server.ClearError ?? ?????? ???????? ????? ?? Page_Error ?? ????? Application_Error ? ????? ???????? ??? ????????? ???????? ?? ?????? <customerrors>??? Web.config. ?? ?????? <customerrors>????? ????? ???? ????? ????? ?? (???? "??? ?????????defaultRedirect) ?? ??? ???? ????? ???????? ??? ??? ??? HTTP ???? ????. ????? ??????? ??? ??????? ?????? ????? ????? ???? ??????? ????????.

?? ???? ???? ???? ?? ??? trapped ?? ?? ?? ????????? ??????? ?? ??????? ????? ?? ??? ??? ??? ?????? ?????. ???? ??? ????? ????? ????? ??? Global.asax ???? ?? ??? ??????? Server.ClearError. ????? ????? ??? ?????? ????? ?? ??? Web.config ????? ?????? ??? ?????? ?????.
  1. ??? ??? Global.asax ?? ?????? ??????.
  2. ????? ?????? ??? Server.ClearError ????? surfaces ????? ?? Web.config ?????.
  3. ??? ????????? ??? Global.asax. ??? ?? ???? ???????? ???????? ?????? ?? ???? ?????? ??? ???: objErr
            Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
            Dim objErr As Exception = Server.GetLastError().GetBaseException()
            Dim err As String = "Error Caught in Application_Error event" & _
                                System.Environment.NewLine & _
                                "Error in: " & Request.Url.ToString() & _
                                System.Environment.NewLine & _
                                "Error Message: " & objErr.Message.ToString() & _
                                System.Environment.NewLine & _
                                "Stack Trace:" & objErr.StackTrace.ToString()
    
            EventLog.WriteEntry("Sample_WebApp", err, EventLogEntryType.Error)
            'Server.ClearError()
            'additional actions...
        End Sub
    					
  4. ?? ?????? ???????? ???????? ??????? ??? ?????? <customerrors>?????? ????? ???????? ??? ???? ?????:
    <customErrors defaultRedirect="http://hostName/applicationName/errorStatus.htm" mode="On">
    </customErrors>
    						
    ??????: ??? ?? ????? ????? ???? ????? ?? ????? "defaultRedirect ???? ???? ???? ??? ??? ????? ???? ???????.
  5. ???? ??? ????? ????? trapped ?? ??? ??????? ??? ???? ??????? ???????? ? ??? ?? ???? ?????? ???? ??? ???? ErrorStatus.htm. ?? ?? ???????? ??????? ??? ??????? ?????? ?? ??? ????? ????????? ???? ?????? ??? ?????? ??? ???? .htm ???? ?????. ?? ?????? ????????? ???????? ??????? ??? ErrorStatus.htm:
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
    </HEAD>
    <BODY>
         <b>Custom Error page!</b>
         <br>
         You have been redirected here from the <customErrors> section of the 
         Web.config file.
    </BODY>
    </HTML>
    					
  6. ??????? ???????? ???????? ??? ??????? ????? ??????? ?? ?? ???? AppEvent.aspx ?? ????????. ???? ??? ??? ??? ?????, ??? ????? ?????? ??? ???? ErrorStatus.htm.
??? ????? ?? ??? ????? ?????? ??? ???? ??????? ???????? ?? ???? ????? "defaultRedirect" ?? ?????? <customerrors>? ????? ????? ????? ???? ????? ?????? ????? ??? ???????? ??? ??? ??? HTTP ???? ????. ???? ???? <error>???? ??? ??????. ??? ???? ??????:
<customErrors defaultRedirect="http://hostName/applicationName/errorStatus.htm" mode="On">
	<error statusCode="404" redirect="filenotfound.htm" />
</customErrors>
				
??????: ?????? ?????? ?? defaultRedirect ?????? <customerrors>??? .htm. ??? ??? ???? ???????GetLastError ?? ???? .aspx (???? ?????? ????? Page_Error ? Application_Error) ? ??? ????? ????????? ?? ????? ???? ??? ?? ??? ???????? ?????? ??? ?? ??? ????? ???????.

????? ????? ?????? <customerrors>??? ??? ????? ??? ?????. ??? ??????? ????? ??? ?????? ?? ????? ???? ????? ??????? ???. ??? ???? ??????? ??? ??? ???? ?????? ??????? ???? ?? ??????? ?????? ????? ????? ASP.NET ?????? ?? ?? ???? ?? ??? ????? ?????? ??? ???? ????? ??????? ??????? ???????? ?????? ????. ????? ??? ??? ????????? ???????:
  • ???: ??????????? ??? ???????? ????? ???????? ??? ?????? ??????? defaultRedirect. ??? ??????? ??? ????? ???? ????? ?? ???????.
  • ?????: ???? ??????? ??????? ??????????? ?? ??? ????? ?????? ??? ???? defaultRedirect. ??? ??????? ??? ????? ???? ????? ?? ?????.
  • RemoteOnly: ??? ????? ?????????? ????? ?????? ??????? ??? ?????? ??????? ??? ????????? ?????? (???????? localhost) ??????? ???????. ??? ????? ????? ???? ?????????? ??????? ??? ?????? "defaultRedirect". ??? ??????? ??? ????? ???? ????? ?? ??? ???????.

??????? ??????? ????????

?? ??????? ????????? ????? ?? ??? ???? ??????? Windows 2000 ? Windows XP ? ASP.NET ??? ????? ????????? ???????? ??????? ??? ?? ????? ????. ???? ??? ??????? ?????????? ???? ???? unprivileged ???? ???? ASPNET. ?? ??????? ???? ?? ASP.NET ? ??? ???? ????? ?????? ???? ?????? ???? ????????? ?????? ?? ??????.

?? ??????? ????????? ????? ?? ??? Windows Server 2003 (IIS6) ? ???? ASP.NET ??? ??? ????????? ???????? ??????? ?? ????? ????. ???? ??? ??????? ?????????? ???? ????? ???? NetworkService.

?????? ?????? ?????????? ??????? ?????? ??? ???? ?? ????????? ??? ??? ??????? ? ????? ???? ???? ??????? ?????? ????????? ???????? ?? ??? ??????? ???????? ??? ????????? ?????? ???????? ?????? ???? ?? ????? ??? ???? ???? ??????.
??????? ??????? ?????? 1 ?? Microsoft .NET Framework
http://msdn2.microsoft.com/en-us/library/ms994923.aspx

?????

????? ?? ?????????? ???? ??? ????? Microsoft ??????? ??? ?????:
????? ????????? ?? .NET
http://msdn2.microsoft.com/en-us/library/ms954599.aspx

?????? ?? ??? ?????????
http://msdn2.microsoft.com/en-us/library/5b2yeyab(vs.71).aspx

????? HttpServerUtility.ClearError
http://msdn2.microsoft.com/en-us/library/system.web.httpserverutility.clearerror(vs.71).aspx

???? ????? .NET MSDN
http://msdn2.microsoft.com/en-us/netframework/default.aspx

?????? ???????? Microsoft .NET
http://www.microsoft.com/net/

???????

???? ???????: 308132 - ????? ??? ??????: 15/?????/1428 - ??????: 5.7
????? ???
  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
????? ??????: 
kbmt kbconfig kbhowtomaster kbweb KB308132 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????308132

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com