Creating a custom 404 asp.net page.

C

craigkenisston

Hi,

I'm going nuts with a supposed simple thing.
I have this page :

<%@ Page language="c#" Codebehind="404page.aspx.cs"
AutoEventWireup="false" Inherits="mydomain._404page" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>

<html>

<script language="C#" runat="server">

void Page_Load(Object sender, EventArgs e) {
Response.Redirect("~/default.aspx");
}

</script>

<head>
<title>404page</title>
<meta name="CODE_LANGUAGE" Content="C#">

</head>
<body>



</body>
</html>


All what I want is to redirect any error to the root.
I already added : <error statusCode="404" redirect="404page.aspx" /> to
the web.config.

The problem is, when a page is mistyped, I am sending to the error
page, but the error page is not redirecting to the root as it should !
What's the problem ?

Thanks in advance.
 
J

Juan T. Llibre

If what you want to do is redirect to /default.aspx,
why don't you do it directly, instead of first redirecting
to 404.aspx and then redirecting again to /default,aspx ?

<error statusCode="404" redirect="/default.aspx" />



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top