views:

824

answers:

2

I am getting this error only SOMETIMES (apparently randomly, though I know there's really no such thing in computers).

I'm working on an MVC (release 1) site in VS 2008. The machine is running Windows 7 with IIS 7, but this instance is running under the Webserver built into VS (Cassini?). When I do an F5 to start running it, I will sometimes get an exception trap at the 4th line of the Page_Load method of Default.aspx.cs:

httpHandler.ProcessRequest(HttpContext.Current);

The exception method is: The incoming request does not match any route.

Examining the HttpContext.Current.Request object shows a path of "/", and a rawUrl of "/Default.aspx?" - i.e, your normal empty request to a site.

The MapRoutes routine is pretty much standard except for a couple of IgnoreRoutes lines (ignore "pics/{imgfile}", and ignore "{favicon}"). The Application_Start routine has configuration for a StructureMap, and a call to SetControllerFactory before the call to RegisterRoutes, but it otherwise standard.

Usually, if I restart VS, the problem goes away. (And almost always if I restart the machine).

Any clues?

Thanks.

+1  A: 

Set a default Page. F5 in asp.net will launch to whatever page is selected. However since in MVC, your View may or may not have an associated controller function, it can be trying to call an action that doesn't exist. Open up your project properties and set the debug start page to your site home controller action.

Russell Steen
Russell,Thanks for taking the time to respond.There is a default page set, and it is the standard code-behind for that default page (Default.aspx.cs) that is running and throwing the exception. There is a start project set, and, all the actions exist, particularly the default action (controller=home, action=index). Since this runs most of the time and only fails intermittentently, it's difficult to see how that could be the problem.
Dave Hanna
A: 

Sorry my poor english ...

I had this problem too! Misteriously the method Application_Start that call the routes disappeared in the Global.asax!!

vb.net:

Sub Application_Start()
    RegisterRoutes(RouteTable.Routes)
End Sub

put this method in global.asax if it doesn't exist

Juliana Machado