1

所以我有一个 MVC Web 应用程序,它目前在 MVC 3,C# 上。

我使用了 MVC 站点地图,并且每隔一段时间我们就会收到此错误:

System.InvalidOperationException: Multiple nodes with the same URL '/Home.mvc.aspx/Index' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs.
Generated: Fri, 18 May 2012 14:46:20 GMT

System.InvalidOperationException: An error occurred when trying to create a controller of type 'StudentPortal3G.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> MvcSiteMap.Core.MvcSiteMapException: An error occured while parsing the SiteMap XML. Check the inner exception for more details. ---> System.InvalidOperationException: Multiple nodes with the same URL '/Home.mvc.aspx/Index' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs.
   at System.Web.StaticSiteMapProvider.AddNode(SiteMapNode node, SiteMapNode parentNode)
   at MvcSiteMap.Core.MvcSiteMapProvider.AddNode(SiteMapNode node, SiteMapNode parentNode) in D:\Project Files\JCDCHelper\WebApp\MvcSiteMap.Core\MvcSiteMapProvider.cs:line 356
   at MvcSiteMap.Core.MvcSiteMapProvider.AddNode(SiteMapNode node) in D:\Project Files\JCDCHelper\WebApp\MvcSiteMap.Core\MvcSiteMapProvider.cs:line 336
   at MvcSiteMap.Core.MvcSiteMapProvider.BuildSiteMap() in D:\Project Files\JCDCHelper\WebApp\MvcSiteMap.Core\MvcSiteMapProvider.cs:line 264
   --- End of inner exception stack trace ---
   at MvcSiteMap.Core.MvcSiteMapProvider.BuildSiteMap() in D:\Project Files\JCDCHelper\WebApp\MvcSiteMap.Core\MvcSiteMapProvider.cs:line 309
   at MvcSiteMap.Core.MvcSiteMapProvider.GetRootNodeCore() in D:\Project Files\JCDCHelper\WebApp\MvcSiteMap.Core\MvcSiteMapProvider.cs:line 365
   at System.Web.SiteMapProvider.get_RootNode()
   at MvcSiteMap.Core.MvcSiteMapProvider.get_RootNode() in D:\Project Files\JCDCHelper\WebApp\MvcSiteMap.Core\MvcSiteMapProvider.cs:line 120
   at System.Web.SiteMap.get_RootNode()
   at StudentPortal3G.Controllers.BaseController.LoadHeaderInfo() in d:\CC\StudentPortal3G\Source\StudentPortal3G\Controllers\BaseController.cs:line 40
   at JCDCHelper.MVCController.JCDCBaseController..ctor(INetLog passNetLog, IUserMaintBLL passUserMaintBLL) in d:\CC\JCDCHelper.MVCController\Source\JCDCHelper.MVCController\JCDCBaseController.cs:line 47
   at JCDCHelper.MVCController.JCDCBaseController..ctor() in d:\CC\JCDCHelper.MVCController\Source\JCDCHelper.MVCController\JCDCBaseController.cs:line 33
   at StudentPortal3G.Controllers.HomeController..ctor() in d:\CC\StudentPortal3G\Source\StudentPortal3G\Controllers\HomeController.cs:line 35
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
   --- End of inner exception stack trace ---
   at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
   at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
   at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<BeginProcessRequest>b__2()
   at System.Web.Mvc.SecurityUtil.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a()
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[TResult](Func`1 func)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

但是我知道这些节点中没有两个,如果是这样,每次都会发生错误。

以前有人经历过吗?

4

1 回答 1

1

我在一个项目上使用 MvcSiteMapProvider,但我不喜欢它。我遇到的问题之一是它不是线程安全的(或者至少这是我的结论)。如果我同时在多个页面上进行第一次加载,我会遇到类似的错误。除了为源代码做出贡献外,我不知道有任何解决方法。我的猜测是 /home 是您的 xml 中的第一个节点,并且当它再次开始运行时它已经加载。

于 2012-05-18T15:35:04.790 回答