ASP.NET Приложение MVC 2 запускается в VS, но с ошибками в IIS

#asp.net-mvc-2 #iis-7 #iis-7.5

#asp.net-mvc-2 #iis-7 #iis-7.5

Вопрос:

Мы унаследовали приложение MVC 2, которое запускается в Visual Studio, но когда мы пытаемся развернуть его на рабочем сервере (Win 2008 x86) или даже на той же локальной машине Win7 x64, но с использованием IIS, AppPool на обоих ASP.NET 4.0 в интегрированном режиме мы получаем ту же ошибку NullReferenceException:

     Server Error in '/' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.PipelineModuleStepContainer.GetEventCount(RequestNotification notification, Boolean isPostEvent)  30
   System.Web.PipelineStepManager.ResumeSteps(Exception error)  266
   System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)  132
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)  709

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 
  

Кто-нибудь еще сталкивался с этим? Приветствуются любые рекомендации.

Спасибо!

Ответ №1:

Одна из возможных причин, о которой я могу думать, заключается в том, что приложение размещено в интегрированной модели, в которой HttpContext недоступен Application_Start . Поэтому, если ваше приложение пытается получить доступ к HttpContext, Request, Response, … это может привести к этому.

Комментарии:

1. Вот и все! Спасибо! Теперь я должен понять, почему, черт возьми, HttpContext недоступен в IIS7… Ну что ж … 🙂

2. В настоящее время я обошелся, разместив его на IIS6. Пока мы не внесем изменения в Global.asax, которые позволят разместить его в интегрированном режиме IIS7. Еще раз спасибо!

Ответ №2:

Удалите тег codedom из tbe web.config, он создаст issse’а. (Я столкнулся с этой проблемой в сообществе VS 2017

 <system.codedom>    </system.codedom>