[NullReferenceException: 未将对象引用设置到对象的实例。] System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +217 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContex

[NullReferenceException: 未将对象引用设置到对象的实例。]    System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +217    System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContex [NullReferenceException: 未将对象引用设置到对象的实例。]
   System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +217
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +69
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +138
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +194
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87 
 
 
.net mvcwebapi报错


#region 不忽略axd文件的说明,线程不安全,导致程序异常
// RouteTable.Routes is not thread - safe.This issue is because some piece of code tried to modify the RouteTable.Routes in a manner which was not thread-safe.

//The best practice is to modify the RouteTable.Routes in the Application_Start. If you have to modify it in a way which can be accessed by multiple threads at the same time, make sure you make it in a thread-safe way.Check the example from MSDN, copied below for ease of reference:

//using (RouteTable.Routes.GetWriteLock())
// {
// Route newRoute = new Route("{action}/{id}", new ReportRouteHandler());
// RouteTable.Routes.Add(newRoute);
// }
//RegisterRoutes(RouteTable.Routes);

//public static void RegisterRoutes(RouteCollection routes)
//{
// //忽略对.axd文件的Route,也就是和WebForm一样直接去访问.axd文件
// routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
// routes.MapMvcAttributeRoutes();


//}