DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Thu, 09 Aug 2007 08:15:52 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Joey
          2    Aidy
          3    Juan T. Llibre


App_Error In Global.asax and HTTP 404 File Not Found   
Why do HTTP 404 File Not Found messages not get trapped and sent into
App_Error in Global.asax, like most other errors/exceptions? How do I
detect it?
Date:Thu, 09 Aug 2007 08:15:52 -0700   Author:  

Re: App_Error In Global.asax and HTTP 404 File Not Found   
I think only application errors (mainly unhandled exceptions) get raised in 
global.asax.  If you want to trap 404 errors then create your own 404 
handling page and configure IIS to use your page rather than the default 
one.

"Joey"  wrote in message 
news:1186672552.890431.256900@r34g2000hsd.googlegroups.com...

> Why do HTTP 404 File Not Found messages not get trapped and sent into
> App_Error in Global.asax, like most other errors/exceptions? How do I
> detect it?
>
> 
Date:Thu, 9 Aug 2007 16:33:38 +0100   Author:  

Re: App_Error In Global.asax and HTTP 404 File Not Found   
re:
!> Why do HTTP 404 File Not Found messages not get trapped and sent into
!> App_Error in Global.asax, like most other errors/exceptions? How do I detect it?

In global.asax :

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
       Server.Transfer("Errors.aspx")
End Sub

Errors.aspx:
-----------------
<html>
<script language="VB" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim errMessage As String = ""
  Dim appException As System.Exception = Server.GetLastError()
  If (TypeOf (appException) Is HttpException) Then
        Dim checkException As HttpException = CType(appException, HttpException)
  Select Case checkException.GetHttpCode
  Case 401
   errMessage &= "You are not authorized to view this page."
  Case 403
  errMessage &= "You are not allowed to view that page."
  Case 404
  errMessage &= "The page you have requested can't be found."
  Case 500
  errMessage &= "The server can't fulfill your request."
  Case Else
  errMessage &= "The server has experienced an error."
  End Select
  Else
  errMessage &= "The following error occurred<BR>" & appException.ToString
  End If
  ErrorMessage.Text = errMessage & "<BR>We're sorry for the inconvenience."
Server.ClearError()
End Sub
</script>
<body>
<hr>
<asp:label id="ErrorMessage" font-size="12" font-bold="true" runat=server/>
<hr>
<p>Return to <a href=http://yourserver.com/> this site's entry page</a>
</body>
</html>
----------



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"Joey"  wrote in message news:1186672552.890431.256900@r34g2000hsd.googlegroups.com...

> Why do HTTP 404 File Not Found messages not get trapped and sent into
> App_Error in Global.asax, like most other errors/exceptions? How do I
> detect it?
> 
Date:Thu, 9 Aug 2007 15:18:11 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us