2

Closed

Orchard Admin Menu via INavigationProvider behaving odd

description

I have noticed that while building a module with an INavigationProvider which links to a custom controller (as per Part 10 of sfmskywalkers web tutorial at http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-10), the admin menu behaves odd while developing.

For instance, when my controller contains an error and I click on the admin menu, I get thrown out of the Dashboard and I land on a "Not Found"-page. When I then go back to the Dashboard and click the admin menu again, it seems as if the anchor-link of the admin menu has no href associated with it, as I simpy open the current admin page again. I can only solve this by changing the position of the admin menu item in the INavigationProvider based class (in the below code by switching "Doopsuiker"and "Fotografie" from 2.1 to 2.2 and reverse). After that, everything works smoothly again. This is my AdminMenu.cs:

public class AdminMenu : INavigationProvider
{
    #region Construction/Destruction

    public AdminMenu()
    {            
        T = NullLocalizer.Instance;
    }

    #endregion Construction/Destruction

    #region Methods

    public void GetNavigation(NavigationBuilder builder)
    {
        builder

            // Image set
            .AddImageSet("webshop")

            // "Webshop"
            .Add(item => item

                .Caption(T("Webshop"))
                .Position("2")
                .LinkToFirstChild(true)

                // "Doopsuiker"
                .Add(subItem => subItem
                    .Caption(T("Doopsuiker"))
                    .Position("2.1")
                    .Action("Index", "DoopsuikerAdmin", new { area = "Orchard.Ekalaya" })
                )

                // "Fotografie"
                .Add(subItem => subItem
                    .Caption(T("Fotografie"))
                    .Position("2.2")
                    .Action("Index", "FotografieAdmin", new { area = "Orchard.Ekalaya" })
                )

            );
    }

    #endregion Methods

    #region Accessors

    public Localizer T { get; set; }

    public string MenuName { get { return "admin"; } }

    #endregion Accessors
}
Closed Oct 17, 2012 at 6:00 PM by sebastienros
Can't repro the issue with the given code. I changed the route to an existing controller throwing an exception, and it's showing an error message on the dashboard and the menu links are still populated.

If you can still repro please provide a more detailed scenario using a vanilla Orchard setup.

comments

2LM wrote Sep 20, 2012 at 5:38 AM

I would like to elaborate on this one a bit further, as I now have a similar issue when building a controller in a custom module for the front-end. It seems it has nothing to do with the menu or INavigationProvider per se, but more with the dynamic compilation that seems to have some stuff cached of which it won't let go.

It's all related to the development experience, while I am developing, and obviously receiving errors, all of the sudden the whole controller route is no longer recognized and I get a page not found. To be ablle to get things running again, I need to close down the browser, restart the site in webmatrix 2 and after that I need to play with the [Themed] attribute on my controller method to have it recompile again and get my route recognized once more.

I do have to say that I am running VS2012 on Windows 8, so I don't know if that has something to do with it, but I am quite sure that the admin menu issue and the controller route stuff is related. I personally believe it's the dynamic compilation that gets a bit mixed up, although I have no proof, as it is so random and I can't debug it in any way. Also, even in this case, no logs at all...

I sure hope you guys can pick this one up, as it is ruiningmy whole development experience with Orchard and I am pulling my hair out as I am doing more work looking for "ghost" issues than actually getting into Orchard development. Thanks in advance.

sebastienros wrote Sep 25, 2012 at 7:24 PM

Can you provide a custom set of steps reproducing an issue and please also describe what the issue is and what you would expect to see.

2LM wrote Oct 3, 2012 at 10:26 AM

Hi Sebastien,

Thanks for your feedback and sorry for the delay of my response. As stated previously, I don't really have exact steps to reproduce as it is not happening every time. What is happening is that when an error occurs in a custom module, menu or controller, I get redirected to a Not Found page. From that point on, my module, menu or whatever seems to be disabled, even though it is not disabled in the installed features list. It seems to be simply ignored. At that point I need to do a full solution rebuild and sometimes play around with admin and themed attributes for my module to be picked up again... Also, I am running VS2012 on Windows 8.

Jetski5822 wrote Oct 10, 2012 at 10:26 PM

Are you running on the tip of 1.x?