Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 404 error on MVC web-site

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:

  • There is no corresponding 404 log entry in IIS logs.
    • Actually, there are 404 entries in the IIS log.
  • The application pool for the web-site is set to use the Integrated pipeline.
  • The "customErrors" mode is set to off.
  • .NET 3.5 SP1 is installed
  • ASP.NET MVC 2 is installed
  • I've used MVC Diagnostics to confirm all MVC DLLs are being found.
  • ASP.NET is enabled in IIS, which we've demonstrated by running the MVC Diagnostics page.
  • KB 2023146 did highlight that HTTP Redirection was off, so we've turned it on, but no joy.

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!

like image 440
RB. Avatar asked Feb 21 '11 16:02

RB.


People also ask

Why am I getting a 404 error on ASP NET MVC?

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.

How do I fix error 404 in web API?

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.

How do I fix 404 error in IIS?

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.

How does global ASAX handle 404 error?

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.


1 Answers

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.

Screenshot of IIS showing location of Request Filtering option

like image 88
RB. Avatar answered Sep 20 '22 05:09

RB.