MVC 4 Areas not working as expected

I created a sample VB project in VS2010 to add Areas

to the web interface, but when I run it you get the following error:

Resource is not found. Description: HTTP 404. A resource that you (or one of its dependencies) may have been removed, changed its name, or is temporarily unavailable. Please review the following URL and make sure it is spelled correctly.

I also added AreaRegistration.RegisterAllAreas()

to the file global.asax

and also tried to manually register the route in the route.config file but nothing works.

routes.MapRoute( _
            "Admin_default", _
            "Admin/{controller}/{action}/{id}", _
            New With {.action = "Index", .id = UrlParameter.Optional} _
            )

      

It looks like it only finds root views, but not a specific view Area

. Any ideas?

+1


source to share


2 answers


Found the answer on another site by posting the solution here:



The same project in C # works fine, but doesn't work in VB. Cause. Controller namespace is incorrect in VB.net. Decision. Change the controller namespace in the vb project to MyApplication.Areas.MyArea.Controllers and then run it, it will be fine.

+1


source


Make sure you add AreaRegistration.RegisterAllAreas () to the first line in Global.asax. As regions must register before registering other routes.



Also there is no default value in the route you specified for the controller. So make sure you include the controller value in the url, or provide the default controller parameter in your route.

0


source







All Articles