2

I am working on a large Sitecore 6.6 MVC site. To be honest, i'm having trouble finding any good information on Google.

My question here is. I am in the Sitecore content editor on a controller rendering. I want this controller rendering to point to an MVC AREA in my MVC project.

In the data section of my controller rendering in Sitecore I have 2 text boxes: Controller and Controller Action

What do I type in the Controller text box to point to my area.

My area is this: <site root>/Areas/UserManagement/ProfileController.cs

I have tried everything. I hope someone can help.

1 Answer 1

3

In the Controller field you'd put Profile to specify your ProfileController and in the Controller Action field you'd enter the name of the Action of the ProfileController that you wish to invoke.

Your UserManagement area will presumably have a UserManagementAreaRegistration class where the area specific routes are defined and this will be called from the ApplicationStart event handler.

That's how to wire up controller renderings. When looking at this there are a few stumbling blocks:

  1. Action name uniqueness. I haven't managed to get the namespace overload of MapRoute to allow for action names that occur elsewhere in the solution.

    public System.Web.Routing.Route MapRoute(string name, string url, object defaults, string[] namespaces)

  2. Yet to be able to get the view resolution process to respect area paths, instead it appears to search the standard view folders determined by controller name. From your example I had to drop a copy of my razor view into ~/Views/UserManagement/ to get it to render.

5
  • Thanks Kevin, Yep, I have everything set up with my AreaRegistration. I was having terrible trouble getting anything to work for an area. I am not at work now but I think I got it to work but now it is not rendering my _Layout.cshtml. Ill have a look tomorrow and respond with where I got up to.
    – RuSs
    Nov 15, 2012 at 11:02
  • Thanks for this again Kevin, I will try your solution but moving the view out of the area just to make it work does not feel right!
    – RuSs
    Dec 6, 2012 at 20:47
  • As a workaround you can reference your view explicity, for example return View("~/Areas/AreaTwo/Views/SimpleArea/Index.cshtml");
    – Kevin Obee
    Dec 13, 2012 at 11:17
  • 1
    RuSs, I've documented the workaround in a blog post on Sitecore and MVC Areas.
    – Kevin Obee
    Jan 5, 2013 at 19:45
  • Thanks again Kevin. Would it be great, though, if we didn't have to do the following: View("~/Areas/AreaTwo/Views/SimpleArea/Index.cshtml"); Good solution for now though.
    – RuSs
    Apr 29, 2013 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.