mvcsitemapprovider , Does MvcSiteMapProvider support “Sql Server” session state?


Does MvcSiteMapProvider support “Sql Server” session state?

Question:

Tag: mvcsitemapprovider

I am trying to use the MvcSiteMapProvider in an application that is configured with SqlServer session state mode. However, I get an exception the moment I call the RegisterRoutes method of XmlSiteMapController class, like this:

public static void RegisterRoutes(RouteCollection routes)
{
    // ...
    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = "" }
        );

    // Add our route registration for MvcSiteMapProvider sitemaps
    MvcSiteMapProvider.Web.Mvc.XmlSiteMapController.RegisterRoutes(routes);
}

Then I get an exception saying

Type 'System.Web.Routing.RouteValueDictionary' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.

This makes me think MvcSiteMapProvider does not support SqlServer session state mode. Does it?

Thanks!


Answer:

Unless you have customized it, MvcSiteMapProvider does not interact with session state in any way. So, it should work with any mode of session state (I haven't tested it with SqlServer mode, so if you continue having issues I suggest you open a new issue about it). Please see How to Make MvcSiteMapProvider Remember a User's Position for an explanation about how it works without session state.

The error posted indicates your application is trying to serialize the System.Web.Routing.RouteValueDictionary, which is not something that MvcSiteMapProvider does.

On a side note, you don't need to call XmlSiteMapController.RegisterRoutes explicitly from an MVC 4 application as long as you have installed the MvcSiteMapProvider.MVC4 NuGet package. This method is called automatically using WebActivator. It is possible you might be having issues by calling it twice.


Related:


Does MvcSiteMapProvider support “Sql Server” session state?


mvcsitemapprovider
I am trying to use the MvcSiteMapProvider in an application that is configured with SqlServer session state mode. However, I get an exception the moment I call the RegisterRoutes method of XmlSiteMapController class, like this: public static void RegisterRoutes(RouteCollection routes) { // ... routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller =...

MvcSiteMapProvider is using ascx


asp.net,asp.net-mvc,asp.net-mvc-5,sitemap,mvcsitemapprovider
I have donwloaded the Nuget package, MvcSiteMapProvider. In one project it only downloaded the razor views. In my other, I have both the Razor and ascx files. Also in that project it is default to using the ascx. I want it to use the razor pages instead. Does anyone know...

MVC5 MvcSiteMapProvider to display full sitemap


twitter-bootstrap-3,asp.net-mvc-5,mvcsitemapprovider
I successfully installed MvcSiteMapProvider, and got the breadcrumbs working and customizing the templates to generate Twitter Bootstrap navbar menu. Everything is honky dory. Now I'd like to have a view which sole purpose would be to display the whole sitemap hierarchy (in a tree structure, nodes would be clickable). I've...

MvcSiteMapProvider “Home” button in menu not working onclick


asp.net-mvc-5,asp.net-mvc-routing,mvcsitemapprovider
I have a menu generated with MvcSiteMapProvider using a helper for bootstrap and routing: Controller Home: [MvcSiteMapNode(Title = "Home", Key = "home")] public ActionResult Index() { return View(model); } Controller Other: [Route("mypageview", Name = "mypage")] [MvcSiteMapNode(Title = "My Page", ParentKey = "home", Key = "mypage")] public ActionResult mypage() { mymodel...

Is it possible to get template from different directory?


c#,asp.net-mvc,mvcsitemapprovider
I'm using the same cshtml files in different projects so I would like to be able to share the same directory, the 'GeneralTemplates'. So using the @Html.Partial("GeneralTemplates/_Header") works like a charm. But with @Html.MvcSiteMap().SiteMapPath("GeneralTemplates/_Breadcrumbs") is doesn't work, this needs to be in the 'DisplayTemplates' directory and then this works @Html.MvcSiteMap().SiteMapPath("_Breadcrumbs")....

Security Trimming MVC Sitemap Provider Nodes With AuthAttribute Based on Route Values


asp.net-mvc,security,claims-based-identity,mvcsitemapprovider
We have a fully working sitemap with many hundreds of nodes configured with sitemap attributes on the actions. These nodes are are security trimmed working perfectly based on claims. All working great and fast. We now have a requirement that certain pages are inaccessible based on a route value. Basically...

MvcSiteMapProvider - Enhanced bootstrap dropdown menu


c#,twitter-bootstrap,asp.net-mvc-5,mvcsitemapprovider,mvcsitemap
I'm trying to build a menu like this: For reference I'm using this library https://github.com/behigh/bootstrap_dropdowns_enhancement @Html.MvcSiteMap().Menu("BootstrapMenuHelperModel") @model MenuHelperModel <nav class="navbar" role="navigation"> <div class="container-fluid menu-container"> <div class="collapse navbar-collapse"> <div class="navbar-header"> <span class="navbar-brand">FAR BACKOFFICE</span> </div> <ul class="nav nav-pills"> @foreach (var node in Model.Nodes) { if...

MvcSiteMapProvider.dll not working in Visual Studio 2013


asp.net-mvc,visual-studio-2010,visual-studio-2013,mvcsitemapprovider
I have a MVC 2 project created in Visual Studio 2010 that use MvcSiteMapProvider.dll and works fine. But when loading the project in Visual Studio 2013, everything else work fine except it crashes at Html.MvcSiteMap().SiteMapPath The error message is An exception of type 'MvcSiteMapProvider.MvcSiteMapException' occurred in MvcSiteMapProvider.dll but was not...

MvcSiteMapProvider MVC5 External URL Re-routing to Home Controller / Index Method


asp.net-mvc-5,mvcsitemapprovider
I'm using MvcSiteMapProvider 4.6.18. Many of my menu items link to external sites; however, the "url" attribute of mvcSiteMapNode is not being carried over to the menu. That is, I can see the url in the source, but the link is referring to the parent mvcSiteMapNode controller and action and...