Reputation: 23
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?
Upvotes: 1
Views: 1637
Reputation: 47726
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"
(source: haacked.com)
More information with IIS 6 MVC setup
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>
Upvotes: 1
Reputation: 23
@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.
Upvotes: 0
Reputation: 5999
You're using areas, have you registered the area routes?
ASP.NET MVC 2 Beta single-project Area registration getting HTTP 404
Upvotes: 0