MvcSiteMapProvider是否支持“Sql Server”会话状态?(Does MvcSiteMapProvider support “Sql Server” session state?)

编程入门 行业动态 更新时间:2024-10-28 14:28:45
MvcSiteMapProvider是否支持“Sql Server”会话状态?(Does MvcSiteMapProvider support “Sql Server” session state?)

我试图在配置了SqlServer会话状态模式的应用程序中使用MvcSiteMapProvider。 但是,当我调用XmlSiteMapController类的RegisterRoutes方法时,我得到一个异常,如下所示:

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); }

然后我得到一个例外说

在Assembly'System.Web中输入'System.Web.Routing.RouteValueDictionary',Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'未标记为可序列化。

这让我觉得MvcSiteMapProvider不支持SqlServer会话状态模式。 可以?

谢谢!

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!

最满意答案

除非您已对其进行了自定义, MvcSiteMapProvider不会以任何方式与会话状态交互。 因此,它应该适用于任何会话状态模式(我没有使用SqlServer模式测试它,所以如果你继续遇到问题,我建议你打开一个关于它的新问题 )。 请参阅如何使MvcSiteMapProvider记住用户的位置,以获得有关如何在没有会话状态的情况下工作的说明。

发布的错误表明您的应用程序正在尝试序列化System.Web.Routing.RouteValueDictionary ,这不是MvcSiteMapProvider所做的事情。

另外,只要安装了MvcSiteMapProvider.MVC4 NuGet包,就不需要从MVC 4应用程序中显式调用XmlSiteMapController.RegisterRoutes 。 使用WebActivator自动调用此方法。 你有可能通过两次调用来解决问题。

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.

更多推荐

本文发布于:2023-07-21 13:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1210739.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   Server   Sql   MvcSiteMapProvider   session

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!