MVCSiteMapProvider 因空对象而崩溃

发布于 2024-12-10 11:06:50 字数 2292 浏览 3 评论 0原文

我正在使用 MvcSiteMapProvider 为我的网站创建菜单。它工作正常,但突然失败并出现错误:

System.NullReferenceException:未将对象引用设置到对象的实例。

这是堆栈跟踪:

[NullReferenceException: Object reference not set to an instance of an object.]

MvcSiteMapProvider.AuthorizeAttributeAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\AuthorizeAttributeAclModule.cs:80
   MvcSiteMapProvider.DefaultAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\DefaultAclModule.cs:61
   MvcSiteMapProvider.DefaultSiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\DefaultSiteMapProvider.cs:178
   System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +17
   System.Web.StaticSiteMapProvider.GetChildNodes(SiteMapNode node) +378
   System.Web.SiteMapNode.get_ChildNodes() +30
   System.Web.SiteMapNode.get_HasChildNodes() +10
   MvcSiteMapProvider.Web.Html.MenuHelper.BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToCurrent) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\MenuHelper.cs:293
   MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper, String templateName, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToCurrent) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\MenuHelper.cs:234
   MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\MenuHelper.cs:31

我想不出我为引入此错误所做的任何更改。所做的唯一更改是由于使用 StyleCop 的结果(例如更改使用顺序、方法、属性等)。有什么想法吗?

I am using MvcSiteMapProvider to create menu for my web site. It was working properly but suddenly failed with error:

System.NullReferenceException: Object reference not set to an instance of an object.

and here is the stack trace:

[NullReferenceException: Object reference not set to an instance of an object.]

MvcSiteMapProvider.AuthorizeAttributeAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\AuthorizeAttributeAclModule.cs:80
   MvcSiteMapProvider.DefaultAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\DefaultAclModule.cs:61
   MvcSiteMapProvider.DefaultSiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\DefaultSiteMapProvider.cs:178
   System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +17
   System.Web.StaticSiteMapProvider.GetChildNodes(SiteMapNode node) +378
   System.Web.SiteMapNode.get_ChildNodes() +30
   System.Web.SiteMapNode.get_HasChildNodes() +10
   MvcSiteMapProvider.Web.Html.MenuHelper.BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToCurrent) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\MenuHelper.cs:293
   MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper, String templateName, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToCurrent) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\MenuHelper.cs:234
   MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper) in c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\MenuHelper.cs:31

I cannot think of any changes I made to introduce this error. The only changes made were due to results by using StyleCop (e.g. alter order of usings, methods, properties, etc.). Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安人多梦 2024-12-17 11:06:50

如果您不需要安全调整(例如节点的权限/角色),请在 web.config 中注册站点地图提供程序时设置 securityTrimmingEnabled="false",这样您就不会再出现此错误。

我在 http://mvcsitemap.codeplex.com/workitem/6337 上提出了问题,但是这可能不是你的问题。

if you don't need security trimming (e.g. permissions/roles for the nodes) set securityTrimmingEnabled="false" on the registration of the sitemap provider in your web.config and you should no longer have this error.

I've raised an issue on http://mvcsitemap.codeplex.com/workitem/6337 but it might not specifically be your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文