[dba-VB] ASP.NET Redirect on 404 error

Jim Lawrence accessd at shaw.ca
Thu Sep 27 00:53:22 CDT 2012


Hi Gustav:

Owning the servers is the best control, where you can just go in to the
configuration of any particular site or a group of sites and set pointer to
the URL for a specific error or group of errors and then place the error
pages response in the site. There is a nice GUI

http://www.iis.net/configreference

Above is a link to documentation for setting configurations for IIS 7 and
IIS 7.5, with samples, using a variety of languages

Jim

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, September 26, 2012 1:56 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] ASP.NET Redirect on 404 error

Hi all

OK, I've made some progress - paying attention to Upper/lower case of Mode:

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
      <customErrors mode="On">
        <error statusCode="404" redirect="Default.aspx" />
      </customErrors>
    </system.web>
</configuration>

Now a not-found page like:

www.example.com/somewrongpage.aspx

is redirected. But:

www.example.com/somethingwrong

still fails with 404.

Any hints?

/gustav


>>> gustav at cactus.dk 26-09-12 17:43 >>>
Hi all

I have an extremely simple site, one page only: Default.aspx

How can I in a simple way redirect all faulty URLs to this page? So that if
the user types:

www.example.com/somethingwrong

the error is trapped and the user gets:

www.example.com/Default.aspx

I have this Web.config file which should do the job, but it doesn't:

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
      <customErrors Mode="On">
        <error statusCode="404" redirect="Default.aspx" />
      </customErrors>
    </system.web>
</configuration>

Aside from this I can google many fancy solutions. Not needed. It just needs
to call the default page.

/gustav


_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com



More information about the dba-VB mailing list