14

How can I link to one of my root controllers from one of my areas?

<% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %>

This gives me an error:

No route in the route table matches the supplied values.

I have a controller named Pagein a folder named Admin in my root controller collection. I can reach this controller by typing \Admin\Page.

This is how I registered the route:

        routes.MapRoute(
            "Admin",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Admin", action = "Index", id = "" }
        );

I was hoping I could address the "Admin" route using this syntax in my view, but that did not work. Any ideas on how to fix it?

Yannick Blondeau
  • 9,465
  • 8
  • 52
  • 74
Martin at Mennt
  • 5,677
  • 13
  • 61
  • 89

1 Answers1

29
<% Html.RenderAction("Action", "Controller", new { area = "" }); %>
Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
  • 1
    Lol.. it actually was that easy. I was just confused by some other blog saying `root` was the "code" for root. But the correct way is blank area. Thank you. – Martin at Mennt Jan 24 '10 at 12:08