???? ID: 306355 - ????? ???????: 29 ??????? 2010 - ??????: 4.0 ????? ????? C# .NET ?? ????? ???? asp.NET ??? ??????? ?? ?????????? ?????? ????? ?? ??? ???? ????
?? ????? ?????????? ???? ????? ???? ?? ?? trap ?? ?? ?? asp.NET ??? ??, ?? ????????? ?? ??? ???????? ???? ?? ??? ????? C# .NET ??? ?? ????? ???? ????? ASP.NET ?? ????? ?????? ?? ???????? Microsoft ?????? ????? ????? (ASP) ???????? ??? ?????? ??? ASP.NET, ??? ?? ???? ????? ?????? ?? ????????? ?? ???? ??????????? ??? ????? ?? ???? ???? ASP.NET ??? ?? ????????ASP.NET ???? ?? ?? ???? ??? ????? ?? ????????? ?? ??? ???????? ??? ?? advances ???????? ???? ??? ???????? ASP ??? ?? ????? "?? ?????? ???? ???? ????" ???? ????????? (??catch-?? ?????? ??????????? JScript ???)? Alternately, ??? ?? Microsoft ??????? ????? ?????? (IIS) 5.0 ??? ??? ???, ?? ?? ????? ????ASPError????? ?????????? ??? ????? ?????? ????? ?? ??? ???????? ??? ???????, ?? approaches ???? ?????? ????ASP.NET ??? ?? ?? ?? ???? ??? ????? ?? ???????? ????????? ?? ?? ?? ?? ???? ?? ?? ?? ???? asp.NET ????????? ?? ????? ?? ??? ?? ?????? ?? ?????? ????? ??? ASP.NET ?? ??? ????? ??????? ?? trap ?? ?? ?? ??, ?? ????????? ?? ??? ???????? ???? ?? ??? ???? ?????? ???? ??:Page_Error,Application_Error, ?? ????????? ??????????? ????? (Web.config)? ????????? ???? ?? ?? ???? ?? ???? ???? asp.NET ??? ?? ?? ???????? ?? ????? ???? ?? ??? ?????????? Although this article describes how to provide custom error pages and general error reporting as it relates directly to ASP.NET, this article does not describe other error handling approaches such as thetry-catch-finallyblock and the Common Language Runtime (CLR) exception system. How to use the Page_Error methodThePage_Errorevent handler provides a way to trap errors that occur at the page level. You can simply display error information (as the sample code to follow does), or you can log the event or perform some other action.???:?? ?????? ??? ???? ???????? ?????????? ?? ??? ???????? ??????? ?????? ??????? ????????? ???? ??? ?? ????????? ?? ??????? ??? ????? ?? ??? ??????? ????????? ??????? ?? ??????? ?? ????????? ?? ??? ?? ?? cautious ???? ????? ?????? ??? ?????? ? ?? ?? ?? ?????? ????? ????, ?? ??? ?????? ??? ?????? ??????? ?????? ????? ????? ??? ??? ?????????? ?? ??? ??? ????? ????????? ???? ?? ??? ?? ??????? ???? ?????? ?? ???? ??? ?? ?????? ??? ?? ?? ?????, ?? ???? ?????? ??? ???? ?? ??? forces throwsPage_Load????? ??????? ????????? ????? ?? ????? ???? ??? demonstrate ???? ?? ????? ?? ???, ????? ????? ?? ???? ????Page_Error????? ???????
???? ??? ??, ???? ????? ?? ???? ?? ???Inherits??? ???????@ ?????directive. ???Inherits???, ????? ?? ??? ??????? ???? ?? ???? ????????? ??????? ???? ?????? ??? ??? ?? ???? ??? ????????? ????, ???? ????? ?????? ????? ??????? ???? ??: 'Project.PageEvent' ??? ????? ?????? ???? ?? Application_Error ???? ?? ????? ???? ?????? ????Page_Errorevent handler, you can use theApplication_Errorevent handler to trap errors that occur in your application. Due to the event's application-wide scope, you can log of application error information or handle other application-level errors that may occur.The sample to follow is based on the precedingPage_Errorcode sample and would be fired if the error inPage_Loadwas not trapped in thePage_Error????? ??????? TheApplication_Errorevent handler is specified in the Global.asax file of your application. Simplicity, ?? ??? ?? ??? ??? ??? ????? ????? ?????? ????? throw, ??? ?????? trap ???? ?? ??? ??? ??? ?????Application_Error????? ?????? Global.asax ????? ?? ?????? ????? ??? ???? ?? ??? ???? ?? ??? ????? ????? ?? ???? demonstrate ?? ????? ???? ????Application_Error????:
Web.config ????? ?? ????? ???? ??????? ?? ??? ????Server.ClearError?????? ??? trap ??Page_Error??,Application_Error????? ??????, ?????? Web.config ????? ?? <customerrors>??? ??? ???????? ?? ?????? ??????? ??? ??? <customerrors>??? ???, ??? ???????? ?????? ????? ?? ??? ??? ???? ???????????? ????? ????????? ?? ???? ??? (</customerrors></customerrors>defaultRedirect) ?? ??? ????? ??? ????? ?? HTTP ?????? ??? ?? ?????? ???? ?? ??? ????????? ????? ?????????? ?? ????? ???? ?????? ????? ?? ???????? ???? ?? ??? ?? ?? ???? ?? ????? ?? ???? ??????? ??? ?????? ???? ?? ?? ???? ?? ????????? ?? ???? ??? ????? ?????? ?? trapped ???? ??, ?? ????? ????? ????????? ???? ??? This section demonstrates how to modify the Global.asax file so thatServer.ClearError?? ??? ???? ??? ????????????, ?????? ?? ????? Web.config ???? ??? ?????? trap ???? ?? ??? ????? ????? ?? ??? ????
Notice that the <customerrors> section includes a </customerrors>modeattribute that is set toOn. Themodeattribute is used to control how the error redirection occurs. For example, if you are developing the application, you most likely want to see the actual ASP.NET error messages and do not want to be redirected to the more user-friendly error page. Themodeattribute includes the following settings:
?????? ?????????? ??????? ??????? ??? Microsoft Windows 2000 ?? Microsoft Windows XP ??, ASP.NET ???? ????? ????????? ??? ??? ????????? ??? ????? ???? ??? ?? ????????? ?? ????? defaults ASPNET ???? ???? ?? unprivileged ??????? ???? ?? ??? ??? ASP.NET ?? ???? ?????????, ??? ????????? ????? ??????, ?? ????? ???????????? ???? ?? ????????????? ?? ??? ?? ???? ?? ???? ??? ??????? ??????? ??????? ??? Windows Server 2003 (IIS 6) ??, ASP.NET ???? ????? ????????? ??? ??? ????????? ??? ????? ???? ??? ?? ????????? ?? ????? defaults ???? ????? ???? NetworkService ??? ???? ??? ?? ???????? ?? ???? ?? ?? ???? ??? ?????? ?? ???? ??? ???, ?? ???? ????? ??? ???????? ????? ?????? ?? ???????? ?? ???? ?? ?? ?? ??? ?? ???? ??? ???? ??????? ?? ??? ????? ??? ?????? ?? ????: ??????? 1 ??????? ???????? Microsoft .NET Framework ?? ??? HTTP://msdn2.Microsoft.com/en-us/library/ms994923.aspx (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/ms954599.aspx) HttpServerUtility.ClearError ???? (vs.71) http://msdn2.Microsoft.com/en-us/library/SYSTEM.Web.httpserverutility.clearerror .aspx (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebHttpServerUtilityClassClearErrorTopic.asp) MSDN .NET ????????? ????? HTTP://msdn2.Microsoft.com/en-us/netframework/default.aspx (http://msdn2.microsoft.com/en-us/netframework/default.aspx) Microsoft .NET ??? ????? http://www.microsoft.com/net/ (http://www.microsoft.com/net/) ???? ???? ???? ??:
???? ?????? ??????????????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??. ?????????? ?? ??????? ????????? ??????? ??:306355
(http://support.microsoft.com/kb/306355/en-us/
)
| ???? ?????? ???? ?????? ??????
????????? ?????? ??????? ???????? ??????
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email

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