In my application i wrote below code for 404.
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim exc As Exception
Dim readdInfo As New NameValueCollection
exc = Server.GetLastError()
Dim httpCode As Integer = CType(exc, HttpException).GetHttpCode()
If httpCode = 404 Then
If TypeOf Context.CurrentHandler Is System.Web.UI.Page Then
Context.Server.Transfer("404.aspx")
Context.Response.Flush()
Context.Response.End()
Else
Context.RewritePath("404.aspx")
Context.Response.Clear()
Context.Response.ClearContent()
Context.Response.ClearHeaders()
**Context.CurrentHandler.ProcessRequest(Context)**
Context.Response.Flush()
Context.Response.End()
End If
End If
End Sub
But when i try to run above program i am getting Context.CurrentHandler is null exception.
If i keep Response.Redirect in place of Server.Transfer I am getting 301 header.
I’ve used http://404checker.com/full-header-checker for header checking
Not sure what you are trying to do but a Response.Redirect is a 302:
Your Context.CurrentHandler check is before the Server.Transfer so that has nothing to do with your null exception.