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

Gustav Brock Gustav at cactus.dk
Wed Sep 26 15:55:40 CDT 2012


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




More information about the dba-VB mailing list