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

Gustav Brock gustav at cactus.dk
Wed Sep 26 10:43:14 CDT 2012


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



More information about the dba-VB mailing list