【问题标题】:ASP.NET MVC 2 app runs in VS but errors on IISASP.NET MVC 2 应用程序在 VS 中运行,但在 IIS 上出错
【发布时间】:2011-05-25 09:53:58
【问题描述】:

我们继承了在 Visual Studio 中运行的 MVC 2 应用程序,但是当我们尝试将其部署到生产服务器 (Win 2008 x86) 甚至同一台本地 Win7 x64 机器但使用 IIS 时,两者上的 AppPool 都是 ASP.NET 4.0 w/集成模式,我们得到相同的 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 

其他人经历过这种情况吗?任何建议表示赞赏。

谢谢!

【问题讨论】:

    标签: asp.net-mvc-2 iis-7 iis-7.5


    【解决方案1】:

    我能想到的一个可能原因是应用程序托管在集成模型中,而 HttpContext 在Application_Start 中不可用。因此,如果您的应用程序尝试访问 HttpContext、Request、Response ......它可能会抛出这个。

    【讨论】:

    • 就是这样!谢谢!现在我要弄清楚为什么 HttpContext 在 IIS7 上不可用......哦,好吧...... :)
    • 我暂时将它托管在 IIS6 上。直到我们对 Global.asax 进行更改以允许在 IIS7 集成模式下托管它。再次感谢!
    【解决方案2】:

    从 tbe web.config 中删除 codedom 标签,它会创建 issse。 (我在 VS 2017 社区遇到了这个问题

    <system.codedom>    </system.codedom>
    

    【讨论】:

      猜你喜欢
      • 2010-12-28
      • 1970-01-01
      • 2016-12-13
      • 2012-02-14
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 2012-09-25
      相关资源
      最近更新 更多