I have an IIS7.5 web-site, on Windows Server 2008, with an ASP.NET MVC2 web-site deployed to it. The website was built in Visual Studio 2008, targeting .NET 3.5, and IIS 5.1 has been successfully configured to run it as well, for local testing.
However, whenever I try and navigate to a page running in IIS7, I get a 404 error.
I have checked the following things:
EDIT
Ok, so we've installed the world's simplest MVC application (the one which is created when you create a new MVC2 project in Visual Studio), and we are still getting 404s on any page we try and access - e.g.
<my_server>/Home/About
will generate a 404.
Any ideas will be greatly appreciated!
The URL does not match any route in the routing table. A suitable controller is not found. A suitable controller action is not found. The status code of the server's response is 404.
A simple solution is to check for the HTTP status code 404 in the response. If found, you can redirect the control to a page that exists. The following code snippet illustrates how you can write the necessary code in the Configure method of the Startup class to redirect to the home page if a 404 error has occurred.
Go to IIS logs and check if there is a sub-status code for the 404 error. Go to Request Filtering in IIS Manager to make sure there is no rule affecting ASP.NET pages. Check if the other websites hosted in IIS work. Create a new website and application pool to try accessing your ASP.NET pages.
StatusCode = 404; Response. StatusDescription = "Page not found"; You can also handle the various other error codes in here quite nicely. Google will generally follow the 302, and then honour the 404 status code - so you need to make sure that you return that on your error page.
We finally nailed this issue by exporting the IIS configuration of a working server, and comparing it to ours.
It was a really obscure setting which had been changed from the default.
IIS ROOT → request Filtering → Filename Extensions Tab → Edit Feature Settings → Allow unlisted file name extensions
This should be ticked.
This can be set at the IIS level, or the site-level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With