views:

65

answers:

3

I have an MVC 2.0 web site that is using Areas. When I go to the default page (localhost/mywebsite/default.aspx), it correctly routes to the correct action in the correct controller and renders the default view correctly.

But on the page I have several Html.ActionLinks, and these do not seem to be able to find the Controller. When I click on the links in the page, I get a 404 error.

The URLs are what I expect: localhost/mywebsite/MyAreaName/Home/Index (for example). I've also tried localhost/mywebsite/Areas/MyAreaName/Home/Index, but this also gives me a 404.

How do I get the Controller to be recognized?

A: 

You probably don't have your IIS settings setup correctly to map the requests correctly.

Is IIS verify that you have set the "Wildcard application maps" to:

c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll

And make sure you have the "Verify file exists" checkbox unchecked.

Walkthrough - read section "IIS6 Extension-less URLs"

alt text

More information with IIS 6 MVC setup

More IIS Info

EDIT: Since your using IIS 7, verify that it is running in integrated mode. If it is running in classic mode the mapping is NOT done automatically just like the way IIS6 works.

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Kelsey
Hi Kelsey, I'm using IIS 7, so the wildcard mappings aren't required. I have other standalone MVC projects that work fine.
Lane
@Lane I didn't realize you were using IIS7, I have editted in some other things to check.
Kelsey
A: 

You're using areas, have you registered the area routes?

http://stackoverflow.com/questions/1769949/asp-net-mvc-2-beta-single-project-area-registration-getting-http-404

Meff
Thanks Meff. I have got the area routes registered, and I've tried various alternatives on how to do that, but none has worked.
Lane
@Lane, have you tried Haacked's route debugger? May be worth a look, perhaps there's something you've overlooked: http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx
Meff
Unfortunately I was unable to get that working in my MVC 2.0 app.I also tried implementing my own ControllerFactory. But that didn't work either.
Lane
Actually, I did get it working using MvcContrib. But the URLs I expect to work continue to generate a 404, so it's not displaying anything.
Lane
@Lane, I think we'd need to see controller definition and actionlink definition. It may be missing a parameter or something that means it can't match the method definition?
Meff
A: 

@Kelsey, I did have the app pool set correctly with integrated pipeline mode. But thanks for leading me down the correct path. I had the required config settings in a web.config in the Area, and not in the root of the web site, so the routing was never applied. I moved the config settings the the root level web.config and everything is working.

Thanks for your help, and Meff, thanks for all your ideas as well.

Lane