简体   繁体   中英

After reboot: NullReferenceException at System.Web.PipelineStepManager.ResumeSteps

(Almost) every morning, after booting my laptop, starting IIS, and browsing to a specific asp.net mvc web application on my PC, I get this exception:

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.PipelineStepManager.ResumeSteps(Exception error) +1781
   System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +130
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +481

After iisreset, this is solved. It only happens at my own laptop, not on a stage or live server where the same asp.net mvc application is running

I already checked:

  • I didn't add any custom eventhandlers in my global.asax
  • I have no custom HTTPModules of my own. I do use ImageResizer, but no eventhandlers are defined for that module (that I'm aware of and can be seen in the code).
  • I did try to move the code from Application_BeginRequest to the global.Asax constructor but ran into another issue because in the constructor I don't have any HttpContext.Current yet.
  • (I know what a NullReferenceException means, so no need to explain that. In this case the exception isn't thrown by my own code.)

I'm using an app pool in Integrated mode on .net CLR version 4.0.30319 Target framework is .Net 4.5.2

my global.asax looks like this:

public class MvcApplication : HttpApplication {

        protected void Application_Start() {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder());
            ModelBinders.Binders.Add(typeof(DateTime?), new NullableDateTimeModelBinder());

            ClientDataTypeModelValidatorProvider.ResourceClassKey = "ValidationMessages";
            DefaultModelBinder.ResourceClassKey = "ValidationMessages";
        }

        protected void Application_BeginRequest(object sender, EventArgs e) {
            CultureInfo ci = new CultureInfo(LanguageHelpers.GetUserCultureName());
            System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
            System.Threading.Thread.CurrentThread.CurrentCulture = ci;
        }

        public void Application_Error(object sender, EventArgs e) {
            if (!Request.IsLocal) {

....

            }
        }
    }

After taking look at error on internet, i think you have two option.

  1. Remove all HTTP Module if any added in your system.
  2. Remove IIS from Control panel --> Programs & Feature --> Turn off/on Window Feature Remove Internet Information Services and reboot and install again.

See if this works or not.

Also, do you getting this error for any other project or maybe create new one and check this out? If yes then probably reintalling IIS will fix this.

Server error '/' Application. - HttpException

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM