2

I'm having a problem with my site:

Custom errors aren't working for me. This should redirect general errors to a page, and 404 errors to another. It works locally but not in the hosted environment.

<customErrors defaultRedirect="GeneralError.aspx" mode="on">
    <error statusCode="404" redirect="404Error.aspx" />
</customErrors>

Edit: Ok i tested the error thing a little more, and it seems to work for pages like:

www.[domain].com/doesntexist.aspx

but not for

www.[domain].com/doesntexist

It only works if i put .aspx there.

Edit: anyone knows how i can make it so it works for both instances?

Mike Ohlsen
  • 1,900
  • 12
  • 21
TheGateKeeper
  • 4,420
  • 19
  • 66
  • 101
  • 4
    I would recommend you post this as two separate questions, because they are probably two separate answers. They don't seem to have anything to do with each other, except for the fact that they are both happening to you, which is irrelevant. – Mike Mooney Sep 06 '11 at 18:06
  • Mike i know they are irrelevant but they are both simple questions, thats why i put them here. – TheGateKeeper Sep 06 '11 at 18:09
  • "Do requests for managed pages that do not exist (i.e. pagenotfound.aspx) get redirected to 404error.aspx? " It should, thats what it did locally. – TheGateKeeper Sep 06 '11 at 18:11
  • @TheGateKeeper please split them out; they don't belong together. How would you choose an accepted answer otherwise? User 'A', answers the first question right, User 'B' answers the second question correctly. Which one gets it? – George Stocker Sep 06 '11 at 18:11
  • @rsbarro i dont know, its on a remote server. But im using asp.net 4 – TheGateKeeper Sep 06 '11 at 18:13
  • @George Stocker split them up... – TheGateKeeper Sep 06 '11 at 18:14

2 Answers2

4

This has to do with your configuration and version of IIS your host is running. In versions of IIS before 7, or if you are running IIS 7 with the "classic pipeline", there are actually two channels that http requests go though. One handles .net requests though ASP.net, and the other pipeline goes to IIS. (i.e. ASPX goes to asp.net and .jpg goes to IIS)

In your case, non existent pages are going to IIS, this your asp.net congi you specified does not apply. I bet if you type in www.[domain].com/doesntexist.jpg it will not go to you custom page but if you type www.[domain].com/doesntexist.aspx it will.

Sp there are several solutions based on what version if IIS you have. If your host is using IIS7, then you can run the site with the Integrated Pipeline, meaning all request go through ASP.net and configuraiton will apply. Here is more info.

If you are not running IIS, you can only fix this by specifying the custom error codes in IIS itself. If this is the case, hopefully your host will allow this.

One other possibility for IIS6, would be to create custom handlers for non .net pages and files, and force them to route to asp.net, then your configuration would apply. This would not be desirable though as it could become a maintenance nightmare and additional code/configuration.

Related SO questions:

IIS overriding custom 404 error page in ASP.NET

How to get Custom Error Pages working for Classic ASP with IIS 7 Integrated Pipeline

Site not redirecting to Default Document in Classic pipeline mode

Community
  • 1
  • 1
Mike Ohlsen
  • 1,900
  • 12
  • 21
  • Wierd.. when i change to integrated pipeline mode, the site stops working! Il look into it more tomorrow. – TheGateKeeper Sep 06 '11 at 19:25
  • I just checked, and my hosting is using IIS7. I did some more work and got my website to run in integrated pipeline mode. But for some reason, it still doesnt work. I tought integrated pipeline mode makes all requests go throu asp.net? So why does one redirect and the other one send the generic error? Btw, i have yet to learn about IIS, scince i am just a beginner i only know a bit of asp.net and css, thats why i dont know these things :) – TheGateKeeper Sep 07 '11 at 17:44
  • Weird. Something must be overrideing it. take a look at http://stackoverflow.com/questions/3166523/asp-net-application-hosted-on-iis7-that-is-ignoring-custom-errors-and-falls-back/3275580#3275580. Maybe need to configure or remove section in the web.config or try Response.TrySkipIisCustomErrors if you have a default error handler. – Mike Ohlsen Sep 08 '11 at 11:16
  • Will try, its amazing how something so minor can be so troublesone. IIS is a beast to tame – TheGateKeeper Sep 08 '11 at 21:03
  • Got it to work with httpErrors, althou it only worked because this was a very simple website. If i had more features like error handling, this wouldnt be a good solution because the exceptions would not be logged. – TheGateKeeper Sep 09 '11 at 18:36
-1

Mozilla Firefox sometimes has a caching issue with favicons. Try navigating your browser directly to the file: http://example.com/favicon.ico. This will load it into Firefox's cache. Close the browser and reload your hosted site.

Check your hosting provider's IIS settings for 404 errors. Check your hosting providers FAQ for IIS settings and 404. They may be disallowing configuration from web.config.

Community
  • 1
  • 1
p.campbell
  • 98,673
  • 67
  • 256
  • 322