2011-05-25 89 views
3

我們繼承了在Visual Studio中運行的MVC 2應用程序,但是當我們嘗試將其部署到生產服務器(Win 2008 x86)或甚至是同一臺本地Win7 x64機器上時,使用IIS,應用程序池兩個是ASP.NET 4.0瓦特/集成模式下,我們得到相同的NullReferenceException錯誤:ASP.NET MVC 2應用程序在VS中運行,但在IIS上運行錯誤

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 

任何人都經歷過這樣?任何意見表示讚賞。

謝謝!

回答

7

我能想到的一個可能的原因是應用程序託管在集成模型中,而HttpContext在Application_Start中不可用。所以如果你的應用程序試圖訪問HttpContext,Request,Response,它可能會拋出這個問題。

+0

這就是它!謝謝!現在我得弄清楚爲什麼赫克的HttpContext不可用IIS7上......呵呵,好了... :) – sergeb 2011-05-27 04:03:15

+0

我工作圍繞通過在IIS6上暫時託管它。直到我們對允許在IIS7集成模式下託管它的Global.asax進行更改。再次感謝! – sergeb 2011-05-29 21:11:18

-2

從web.config中移除codedom標記,它創建issse。 (我在2017年VS面對這個問題社區

<system.codedom> </system.codedom> 
相關問題