Fixing 404 Errors under MVC w/ IIS6
Posted by Michael Bray on December 30, 2008
I’ve run into this three times now, and you would think that one of the first two times I would have figured out exactly what the issue was. Robert helped me fix this the first time, then I was able to duplicate it last night on another box, but I hit it again when I tried to make some configuration changes on the first box. I have a rule that any issue that bite me three times gets extra attention, thus this post. Writing about it forces my brain to push it into long-term memory, and hopefully if anyone else runs into the same problems, this will help.
The symptoms are this: you’re running MVC (preview 5 as of this writing) on IIS6. Opening the root of your application may work, but trying to navigate to a controller fails with a 404 error. So you did some research, and you probably found some links… Omar’s blog talks about several different issues, the first of which is most relevant to this issue. He links to several forum posts, several of which contain a wonderful and easy solution (even if not the best solution), specifically, adding a wildcard application map in the Application Configuration. Wildcard application maps may not be the best solution, but they are easy. (Here’s a better way to do it.)
So you go an add your wildcard application map by clicking the Insert button to the right of the Wildcard application mappings (don’t confuse yourself and click ‘Add…’ under Application Extensions (see the image below).
So you think you fixed it…. you go back to your page and you STILL get the 404 errors. You do everything from restarting IIS to rebooting the server to checking every permission and configuration setting you can find, but nothing works.
Well it turns out there is a bit of a misleading option that is critical to this working. When you add the wildcard application map, you MUST uncheck the option “Verify that file exists.” As I mentioned, there are several posts (here’s another) that talk about this, but it’s easy to overlook, especially if you are a ‘read every other word’ type of person like I am. Worse, several other Google search results tell you to add the wildcard mapping but don’t say anything about the “Verify” option.
Let me repeat this for those of you that are like me:
YOU MUST UNCHECK THE OPTION “VERIFY THAT FILE EXISTS”
This option does NOT mean “Make sure that ASPNET_ISAPI.DLL exists”… it means “make sure the file that the user is requesting exists”. Thus, if you do not uncheck this option, the server will see that the MVC page that the user is requesting doesn’t really exist as a file on disk, and will report a 404 error.
There. I think that should be enough self-flogging for now.