1
votes

I've read numerous blogs, forum questions and answers, including a bunch here on SO, but still can't figure this one out.

I'm trying to learn MVC3 by running a template MVC3 project out of the box, not changing any code, and I get a 404 error.

I try to navigate to http://localhost:<port>/Home and then http://localhost:<port>/Home/Index same results.

Literally I haven't changed anything. Here are the steps I took:

  1. New Project...
  2. Visual C# > Web > ASP.Net MVC 3 Web Application (give it a name and then press OK)
  3. Chose "Internet Application" and check "Use HTML5 semantic markup" (OK)
  4. Hit F5...

And BOOM! 404 with the usual message:

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /

What am I missing?

I tried adding those to the web.config files:

<add key="enableSimpleMembership" value="false" />

OR

<add key="autoFormsAuthentication" value="false" />

to no avail.

My Global.asax.cs has the original routing code:

public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

      routes.MapRoute(
          "Default", // Route name
          "{controller}/{action}/{id}", // URL with parameters
          new { controller = "Home", action = "Index", id =

UrlParameter.Optional } // Parameter defaults );

  }

But still the dreaded 404 when I press F5... Please help! :(

2
Any chance there is a dot in the name of the folder? It is my understanding that routing can be messed up in Cassini when that is the case.itsmatt
@itsmatt - I always put a dot in my folder names and have never had a problemMartin
@Martin - that's good. Just mentioning it because I remember reading it on an MSDN migration from 3.5 SP1 page - dealing with websites, though I re-read the OP's question again and it mentioned web application, which I think worked fine in this instance.itsmatt
Are you using the built-in development web server or IIS?Darin Dimitrov
There is no dot in my folder name and I'm using the built-in development web server.Lancelot

2 Answers

0
votes

Check to make sure your .NET Framework version in your app pool in IIS matches the version of the framework you are using. I had this problem and it was because the app pool had defaulted to 2.0 and I was using 4.0 in my project.

0
votes

Make sure your controller contains a "Controller" ending for example home - homeController yourcontroller - yourcontollerController Etc.