1

I have a Custom 404 page written in classic ASP that's worked well for a couple of years. Suddenly, instead of seeing he expected nice 404, instead we're seeing a 500- internal server error.

There's nothing been changed in the IIS config (not deliberately, anyway).

Is this just IIS having a tantrum, running out of something? Might a restart fix it? Or is this a sign of something more serious?

IIS 7.5 on Windows 2008 R2.

At Nathan C's instigation, I've remote desktopped to the server and run this locally, and I get a more detailed error response. Top tip, by the way: didn't realise you could get a different result locally!

It seems to be saying that there's something wrong with the config.

I have two custom error pages, one for 404 and one for 410.

The 410 one works fine.

The detailed error response seems to be somehow confusing the two:

Cannot add duplicate collection entry of type 'error' with combined key 
attributes 'statusCode, subStatusCode' respectively set to 410,-1.

I've looked in the web.config and the errors section contains:

<httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="410" path="/custom410.asp" responseMode="ExecuteURL" />
            <error statusCode="404" path="/custom404.asp" responseMode="ExecuteURL" />
</httpErrors>

It strikes me that something is wrong with that page. It references the 404 twice but the 410 only once; there's either something extra or something missing.

But I'm not sure how it's meant to look.

  • If you visit the site from localhost, does it show the detailed error message? – Nathan C Feb 28 '14 at 12:57
  • @Nathan C Yes, it does. And I'm puzzled by what it says: It says: Cannot add duplicate collection entry of type 'error' with combined key attributes 'statusCode, subStatusCode' respectively set to 410,-1. I've looked in the web.config and the errors section contains: `` `` – Marc Wilson Feb 28 '14 at 13:17

2 Answers2

1

IIS 7 is very picky with its configuration files as you've noticed. To fix, delete the entire httpErrors section from web.config, reload IIS, then use the "Error Pages" option in IIS Manager to add what you need.

Nathan C
  • 14,901
  • 4
  • 42
  • 62
  • I thought it looked odd. I'll try what you suggest- it does look as though something is corrupted. – Marc Wilson Feb 28 '14 at 13:47
  • Oh, this gets worse. I removed the section, did an IIS bounce, and then added back the 404 page. That worked fine (if differently) externally and internally. Then I added the 410 custom error back in- and we're back to square one. – Marc Wilson Feb 28 '14 at 13:56
  • That's...odd. It doesn't like the 410 status apparently. Let's see what else I can dig up. – Nathan C Feb 28 '14 at 13:59
  • Try removing the stanza. It may not be needed to override the default. – Nathan C Feb 28 '14 at 14:03
  • What's really irritating is that it used to work. I've added a couple of new rewrite rules recently, to return 410's for some removed content, but the 404 and 410 used to work nicely side by side. Oh- and disabling the rewrite rules doesn't make the problem go away. – Marc Wilson Feb 28 '14 at 14:32
  • That gives a *different* error: ``Cannot add duplicate collection entry of type 'error' with combined key attributes 'statusCode, subStatusCode' respectively set to '404, -1'`` – Marc Wilson Feb 28 '14 at 14:48
  • I'm now in a state where the 410 works but the 404 doesn't. – Marc Wilson Feb 28 '14 at 14:51
  • It's as though it's treating 410 as a subset of 404, somehow. – Marc Wilson Feb 28 '14 at 15:01
  • I'm...at a loss of ideas unfortunately :( hopefully someone else will see this and give some clues. – Nathan C Feb 28 '14 at 15:18
  • I've tried renaming the web.config file to web.config.old, and this "cures" the problem, in the sense that it goes back to IIS default behaviour, but then of course I've lost my custom pages. So it would appear to be definitely something to do with the config sections. I may try a reboot and reinstate of the rules. – Marc Wilson Feb 28 '14 at 16:51
1

What seems to have done the trick is:

<httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <remove statusCode="410" subStatusCode="-1" />
        <error statusCode="404" path="/custom404.asp" 
responseMode="ExecuteURL" />
        <error statusCode="410" path="/custom410.asp" 
responseMode="ExecuteURL" />
</httpErrors>

.. which implies that it was inheriting some behaviour from a higher level (though I'm damned if I can see where).

In that sense, it's a bit of a brute-force method, as I'm still not totally sure of the reason it broke in the first place. It may be that it's inheriting the behaviour from a stupid default setting (it's Microsoft; they have previous).

Thanks to Sam Morgan of Servwise for pointing me in the right direction.