我聽說了Softsys Hosting的好處,所以我決定將我的ASP.NET MVC解決方案移交給他們。但它不會運行在他們身上。我能夠找到我的BeginRequest事件處理程序的問題。如果我有他們,我會得到一個錯誤。這是我的代碼。爲什麼我的主機(softsyshosting.com)不支持BeginRequest和EndRequest事件處理程序?
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
this.BeginRequest += new EventHandler(MvcApplication_BeginRequest);
this.EndRequest += new EventHandler(MvcApplication_EndRequest);
}
void MvcApplication_EndRequest(object sender, EventArgs e)
{
}
void MvcApplication_BeginRequest(object sender, EventArgs e)
{
}
我可以通過創建默認的ASP.NET MVC應用程序並添加上面的代碼來重現該問題。奇怪的是,這段代碼在我的舊主機上運行良好,它只在我的新(共享)主機上崩潰。如果我在我的代碼,這些事件處理程序我得到這個錯誤:
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.GetStepArray(RequestNotification notification, Boolean isPostEvent) +27 System.Web.PipelineModuleStepContainer.GetEventCount(RequestNotification notification, Boolean isPostEvent) +11 System.Web.PipelineStepManager.ResumeSteps(Exception error) +205 System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +91 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +514
我試着用Softsys解決此,但他們不是非常有幫助,基本上他們只是證實,我已經打開了「ASP.NET管道(MVC)「功能在我的管理控制面板中。
有人能:
- 告訴我,如果我編寫一些錯誤
- 給我一個解決
- 向我解釋爲什麼這個錯誤是發生在一臺主機上,而不是其他。
那不是寧可爲支持您的主機供應商的問題? – 2009-07-14 06:27:43
你是否在使用NHibernate? – 2009-07-14 06:32:40