Jun 27, 2012
Jun 25, 2012
Jun 8, 2012
Handle Error on Web.Config file.
I prefer to use a generic error page, and redirect from there :
<system.web>
<customErrors mode="On" defaultRedirect="Errors.aspx"/>
</system.web>
And, in errors.aspx :
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 400
errMessage &= "Bad request. The file size is too large."
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 408
errMessage &= "The request has timed out."
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/>our entry page</a>
</body>
</html>
---------------
<system.web>
<customErrors mode="On" defaultRedirect="Errors.aspx"/>
</system.web>
And, in errors.aspx :
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 400
errMessage &= "Bad request. The file size is too large."
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 408
errMessage &= "The request has timed out."
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/>our entry page</a>
</body>
</html>
---------------
Subscribe to:
Posts (Atom)
-
Remarks This property specifies the appearance of the embedded Windows Media Player. When uiMode is set to "none", "mini...
-
<body> <form id="form1" runat="server"> <img class="RibbonL" src="Imag...
-
Partial Class Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Lo...
What is the use of n-tier architecture and 3-tier architecture?
how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it ...