-
custom 404 page
Is there a way that I can code an aspx for the 404 page to get the string. For instance, if the user puts http://website.com/username, and IIS thinks it doesn't exist, then I will redirect to that aspx page and get the username out of that URL, and do another redirect, is it possible?
-
Re: custom 404 page
One method ..Add global.asax file in your application. Handle the Application_Error Event
Code:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim ex As Exception = Server.GetLastError
Dim exWeb As System.Web.HttpException = TryCast(ex, System.Web.HttpException)
Dim uri As System.Uri = Request.Url
'If Error code is File not exits redirect to the parent
If exWeb.ErrorCode = -2147467259 Then
'Redirect
'Get the URL'
'Either by
'uri.LocalPath
End If
End Sub
-
Re: custom 404 page
Hey,
Dana is perfectly correct.
Here is some more information:
http://aspnetresources.com/articles/...rrorPages.aspx
Gary
-
Re: custom 404 page
If it's IIS doing the "thinking" then .net may not even be handling the request. For example the page/url does not end in .aspx etc then no asp.net code can execute.
If this is the case there are various ways you could get asp.net to handle the request like
in IIS set a aspx page to be showen as the default 404 error page and do your thing on that page. Or you could write your own httpHandler or maybe HttpModule if you google them heaps of info will come up.