Mvcsitemapprovider with ajax

Asked

Viewed 70 times

2

So, I’m trying to assemble a menu through ajax requests using also Mvcsitemapprovider, but when I try to access mine CurrentNode in my ajax request, is giving as null

My request ajax

$.ajax({
                url: '@Url.Action("MenuVisoes", "Menu", new { area = ""})',
                contentType: 'application/html; charset=utf-8',
                type: 'GET',
                dataType: 'html'
            })
                .success(function (result) {
                    $('#menuVisoes').html(result);
                });
        });

My action

public ActionResult MenuVisoes()
        {

            var currentNode = MenuHelper.GetCurrentNode(MvcSiteMapProvider.SiteMaps.GetSiteMap());
            //buscar no banco os submenus para o centro de trabalho atual

            if (Request.IsAjaxRequest())
            {
                return PartialView("_MenuVisoes", dados);
            }
            else
            {
                return View("_MenuVisoes", dados);
            } 
        }

I tried to catch the CurrentNode so also MvcSiteMapProvider.SiteMaps.Current.CurrentNode, but is always returning null However, if I put it that way in my view, it shows right my current knot.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.