加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – System.Web.Routing.RouteCollection.GetRouteData中的异

发布时间:2020-12-15 08:38:20 所属栏目:百科 来源:网络整理
导读:我在iis7上运行的asp.net mvc代码中随机获得了两个异常: Exception type: InvalidOperationException Exception message: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(Excepti
我在iis7上运行的asp.net mvc代码中随机获得了两个异常:
Exception type: InvalidOperationException 
Exception message: Collection was modified; enumeration operation may not execute. 
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List'1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List'1.Enumerator.MoveNext()
   at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext)
   at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context)
   at System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender,EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)

Exception type: NullReferenceException 
Exception message: Object reference not set to an instance of an object. 
   at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext)
   at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context)
   at System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender,Boolean& completedSynchronously)

它不是一贯可重复的,但我认为这是改变(或腐败)RouteTable.Routes的东西.我在项目中访问RouteTable.Routes的唯一地方是Global.asax.cs,我知道那里的代码只被调用一次,所以这不是问题所在.有关如何追踪它的任何想法?

解决方法

在我的例子中,它最终成为HttpModule: Ext.Direct.Mvc(ASP.NET MVC的Ext.Direct).该模块有一个错误(在0.8.0版本中已修复),每次为IHttpModule调用Init()时都会再次注册路由. ( which might be called multiple times).如果时机正确,它将破坏RouteTable.Routes集合,并导致上述两个例外之一.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读