Results 1 to 2 of 2

Thread: HTTP Error 404.0 - Not Found

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    243

    HTTP Error 404.0 - Not Found

    I'm using Errorhandler in my web application in vs 3.5

    But when anyone enters www.myurl.com/abc or www.myurl.com/wrongurl.htm or html

    he got error
    HTTP Error 404.0 - Not Found

    So, I changed some of setting in my web.config and global.asax
    Here is my code for both.

    web.config

    <customErrors mode ="On" defaultRedirect ="~/Errorpage.htm">
    <error statusCode ="404" redirect ="~/Errorpage.htm"/>
    </customErrors>

    <system.webServer><validation validateIntegratedModeConfiguration="false"/>
    <httpErrors errorMode ="Custom">
    <remove statusCode ="404" subStatusCode ="-1"/>
    <error statusCode ="404" path="~/Errorpage.htm" responseMode ="ExecuteURL"/>
    </httpErrors>

    </system.webServer>


    global.asax

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

    Dim lastError As Exception = Server.GetLastError()
    If (lastError IsNot Nothing AndAlso lastError.Message <> "File does not exist.") AndAlso (lastError.Message <> "Thread was being aborted") AndAlso (lastError.Message <> "The client disconnected.") Then
    Dim errMessage As String = ""
    If (TypeOf (lastError) Is HttpException) Then
    Dim checkException As HttpException = DirectCast(lastError, HttpException)
    Dim httpErrorCode As Integer = checkException.GetHttpCode()
    Server.ClearError()

    Select Case httpErrorCode
    Case 401
    errMessage += "You are not authorized to view this page."
    Response.Redirect("~/Errorpage.htm")
    Exit Select
    Case 403
    errMessage += "You are not allowed to view that page."
    Response.Redirect("~/Errorpage.htm")
    Exit Select
    Case 404
    errMessage += "The page you have requested can't be found."
    Response.Redirect("~/Errorpage.htm")
    Exit Select
    Case 500
    errMessage += "The server can't fulfill your request."
    Response.Redirect("~/Errorpage.htm")

    Exit Select
    Case Else
    errMessage += "The server has experienced an error."
    Response.Redirect("~/Errorpage.htm")
    Exit Select
    End Select
    Else
    Server.ClearError()
    Response.Redirect("~/Errorpage.htm")
    End If
    Else
    Server.ClearError()
    Response.Clear()
    End If
    End Sub


    Now I'm not getting 404 Error but It shows me blank page
    Means if there is any error then it properly goes to errorpage.htm
    But for 404 error it goes to blank page.
    My errorpage.htm is in root directory itself.
    What could be the cause.?

  2. #2
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    India
    Posts
    310

    Re: HTTP Error 404.0 - Not Found

    Change the setting in IIS. remove your error page or change setting off. you will get the error.
    Sagar
    VB6, VB.net,C#,ASP, ASP.net MSSQL, MYSQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width