473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Global Redirect

How can I cause all requests for [pages that no longer exist in a Web site]
to result in the user receiving default.aspx?

Thanks!
Nov 19 '05 #1
2 1347
You're looking for a 404 error handler.

http://www.dotnetjohn.com/articles.aspx?articleid=42

<configuration>
<system.web>
<customErrors mode="on"
defaultRedirect="customerrors.aspx?err=Unspecified ">
<error statusCode="404"
redirect="customerrors.aspx?err=File+Not+Found"/>
</customErrors>
</system.web>
</configuration>
A Google search will turn up several techniques including these:

http://www.aspemporium.com/tutorials.aspx?tid=15

http://www.startvbdotnet.com/aspsite/forms/debug.aspx

Setting Status Code Errors

While browsing the Internet you might have come across these kind of error
messages, Page not Found, You are Not Authorized to View this page, HTTP
Error 404 - File or directory not found, etc. This type of errors are called
as status code errors and you can set these kind of errors in the ASP.NET
Web.Config file. The type of error will be identified by the HTTP status
code. The Web.Config file for that looks like this:

<configuration>
<system.web>
<customErrors mode="RemoteOnly"
DefaultRedirect="http://startvbdotnet.com/Error.aspx"/>
<error statuscode="404"
redirect="http://startvbdotnet.com/errorpages/notfound.aspx"/>
<error statuscode="403"_
redirect="http://startvbdotnet.com/errorpages/notauthorized.aspx"/>
</customErrors>
</system.web>
</configuration>
"Smithers" <A@B.com> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
How can I cause all requests for [pages that no longer exist in a Web
site] to result in the user receiving default.aspx?

Thanks!

Nov 19 '05 #2
In your Web.Config you can handle it as such

<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly">
<error statusCode="404"
redirect="Default.aspx"/>
</customErrors>
This should be added to he System.Web or merged with existing markup.

It hsould be noticed that this will only work for files that asp.net is
handling. Meaning if somebody requests bleah.html it will use the
default IIS 404 handler.

In order to get this behavior for all files you should set a custom 404
handler through IIS for that application/website.
This may or may not be offered by your web hosting company if you are
hosting with a ISP and you should contact them regarding this if so.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: MostlyH2O | last post by:
Hi Folks, I'm having a hard time getting my Session_OnEnd event to fire in my global.asa. Here's what I have: <SCRIPT LANGUAGE=VBSCRIPT RUNAT=Server> SUB Session_OnStart Session.TimeOut =...
3
by: Steve Mauldin | last post by:
This is a standard ASP application that has several pages at the root withthe global.asa. I set a session variable session("accountid") = "123456" within an asp page and then response.redirect to...
3
by: JP | last post by:
I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event...
1
by: spamfurnace | last post by:
Hello. I have a common area of a website that sales agents use. I got sick and tired of typing response.redirect(path) so i implemented a shared function in Global that i can call and all i have...
5
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect...
5
by: Piz | last post by:
I've read a previous discussion about the same topic, but there's a difference. I call HttpContext.Current.Response.Redirect("file.txt") from a ownmade sub in the global.asax. That doesn't works,...
7
by: Jonas | last post by:
Hi! I have an Application_Error method in global.asax that uses Server.Transfer to move execution to a custom error page. This works fine when an exception is thrown in one of the aspx or ascx...
6
by: ad | last post by:
I have set customErrors to On and set a defaultRedirect in Web.config like: <customErrors mode="On" defaultRedirect="~/ErrorPage/GenericErrorPage.aspx"> When I throw a exception in Global.asax...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
0
by: daonho | last post by:
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim strPath As String = HttpContext.Current.Request.Path() Dim cookie As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.