0

This is an annoyance that I've experienced for a long time, but now my client is asking me to address it.

In every route that gets generated (by a non-Default route), a query string value gets appended: "Area="

As an example:

// RouteConfig.Register():
routes.MapRoute(
    "ProfileDetails",
    "{slug}",
    new { controller = "Profile", action = "Details" }
);

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
);

To generate a URL to the BadgeController.Index action, the Default route will be applied and the result will be /Badge... and that's what is expected.

But to generate a URL to the ProfileController.Details(someUser) action, the ProfileDetails route will be applied and the result will be /someUser?Area= ... which will work, but the ?Area= is unnecessary and messy.

I have no areas in my project. How do I get rid of that Area= query string value? This happens with all of my routes that are not the predefined Default route, not just the "ProfileDetails" one in this example.

I've tried removing the AreaRegistration.RegisterAllAreas() from my Global.asax file, since I assume it's not required.

Jay Querido
  • 1,257
  • 1
  • 12
  • 15
  • Do you use T4MVC? http://stackoverflow.com/questions/6755729/t4mvc-url-actionmvc-controller-action-renders-area-parameter-in-queryst – Brandon Jul 24 '12 at 16:32
  • I do... I should have mentioned that. – Jay Querido Jul 24 '12 at 16:40
  • Wow. I searched long and hard to avoid this from happening. "Area=" (with the quotes) doesn't find that question on SO or Google. Thanks @Brandon! If you put your reference as an answer, I can mark it. – Jay Querido Jul 24 '12 at 16:46

0 Answers0