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?

6
  • 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. Commented Sep 6, 2011 at 18:06
  • Mike i know they are irrelevant but they are both simple questions, thats why i put them here. Commented Sep 6, 2011 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. Commented Sep 6, 2011 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? Commented Sep 6, 2011 at 18:11
  • @rsbarro i dont know, its on a remote server. But im using asp.net 4 Commented Sep 6, 2011 at 18:13

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

5 Comments

Wierd.. when i change to integrated pipeline mode, the site stops working! Il look into it more tomorrow.
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 :)
Weird. Something must be overrideing it. take a look at stackoverflow.com/questions/3166523/…. Maybe need to configure or remove <system.webServer><httpErrors> section in the web.config or try Response.TrySkipIisCustomErrors if you have a default error handler.
Will try, its amazing how something so minor can be so troublesone. IIS is a beast to tame
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.
-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.

1 Comment

Does what show for me? There is no indication on how to get to your hosted site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.