Friday 15 January 2010

asp.net mvc 4 - MVC4 Default route when using areas -


I am trying to use the areas within the MVC app, I like that the default route is to the Home Controller Will be resolved within the admin area but it resolves the root controller on the home site. I added the namespace of the Admin Home Controller but it still solved the Root Home Controller.

My Route Config:

  Public class root config {public static zero registrations (Route quality path) {Routes.IgnoreRoute ("{resource} .Xd / {* pathInfo } "); ("Default", "{controller} / {action} / {id}", New {controller = "Home", Action = "Index", ID = UrlParameter.Optional}, New [] {"MvcApplicationAreas area. Controller "}); }}   

Administrator area route

  public class administratorArera registration: area registration {public override string area name {{return "administrator"; }} Public Override Blank Register Array {Arizona Registry} }); }}   

Home Controller - Admin Area

  Namespace MvcApplicationAreas.Areas.Admin.Controllers {Public Class HomeController: Controller {Public ActionResult Index} {Return View (); }}}   

Why do not any ideas get cured properly? Thank you

I have tested your code for field registration and it works and the right controller Selects. However, the visual resolution sees the view in the root folder, even if the correct controller is used.

To test, I used the following Home Index action in my home controller:

  Public Performance Index () {Return View (Model: "Admin Area home controller "); }   

then my index.chstml in / view / home:

  root view: @modal   

and Administrator area view: While running, the output is:

Route view: home admin in the admin area P> So the path runs the administrator administrator in the admin area, but then thew visual resolution runs and finds the root



No comments:

Post a Comment