仅在生产中,当用户点击我们的登录屏幕时,我们会收到以下 elmah 错误
System.NullReferenceException: Object reference not set to an instance of an object.
Generated: Wed, 24 Apr 2013 16:50:35 GMT
System.NullReferenceException: 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, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
不幸的是,那里并没有给我任何提示!
我的猜测是,这是某种负载下的赛车条件,当它们试图使用时,路线还没有完成。但这只是一个猜测。
有没有人见过这个错误?
我们正在 GlobalAsax Begine Request 方法中加载路线。
protected void Application_BeginRequest()
{
if(RouteTable.Routes.Count == 0) {
XmlConfigurator.Configure();
ILog log = LogManager.GetLogger("MainLog");
log.Info("Logger started");
//AreaRegistration.RegisterAllAreas();
//log.Info("RegisterAllAreas done");
RegisterRoutes(RouteTable.Routes);
log.Info("RegisterRoutes done");
try
{
BootstrapStuctureMap.Bootstrap();
log.Info("Done Bootstrapping");
BootStrapAutoMapper.Configure();
log.Info("Done Automapping");
}
catch (Exception ex)
{
log.Error("Error in Application_Start: ex = " + ex);
throw;
}
ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
log.Info("Done Building StructureMapControllerFactory");
ModelBinders.Binders.DefaultBinder = new CustomModelBinder();
ModelMetadataProviders.Current = new AnnotationsAndConventionsBasedModelMetaDataProvider();
}
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("elmah.axd");
// you have to add this IgnoreRoute so that the PDFX pages get handled like a regular *.aspx page, not a MVC page. - EWB
routes.IgnoreRoute("{resource}.pdfx");
routes.IgnoreRoute("{*favicon}", new {favicon = @"(.*/)?favicon.ico(/.*)?"});
routes.MapRoute("StudentLookup_Return",
"StudentLookup/StudentLookup/{nextAction}/{nextController}",
new
{
controller = "StudentLookup",
action = "StudentLookup"
}
);
routes.MapRoute("StudentLookup_Id",
"StudentLookup/StudentLookup/{Id}",
new
{
controller = "StudentLookup",
action = "StudentLookup",
Id = UrlParameter.Optional
}
);
routes.MapRoute("Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
} // Parameter defaults
);
}
我们认为它是在一些新服务器在线购买后出现的,因此它可能与这些服务器的配置方式有关。
我有点像在这里扔一个冰雹玛丽,有人以前见过这个并且想通了!
任何帮助是极大的赞赏。