將ASP.NET MVC 3.0與Visual Studio 2010(SP1以前版本和SP1)以及ASP.NET Development服務器一起使用出現錯誤「_AppStart爲」時無法創建存儲範圍每次我調試時都會執行「」。當我等待幾秒鐘並刷新瀏覽器時,它按預期工作。當_AppStart執行時無法創建存儲範圍
- 這是否發生在每個人身上?
- 有沒有辦法阻止它?
- 我應該在生產中關注這個嗎? (IIS 6/7託管)
相關work-item #7828 on codeplex沒有官方回覆。
完整堆棧跟蹤:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Storage scopes cannot be created when _AppStart is executing.
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.InvalidOperationException: Storage scopes cannot be created when _AppStart is executing.
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:
[InvalidOperationException: Storage scopes cannot be created when _AppStart is executing.]
System.Web.WebPages.Scope.AspNetRequestScopeStorageProvider.set_CurrentScope(IDictionary`2 value) +83361
System.Web.WebPages.Scope.ScopeStorage.CreateTransientScope(IDictionary`2 context) +95
System.Web.WebPages.Scope.ScopeStorage.CreateTransientScope() +76
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +84
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8862381
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
你與IIS快遞(運行時,與VS 2010 SP1可以解決),而不是Web開發工作室? – Linkgoron 2011-03-21 21:52:43
@Linkgoron我剛剛使用VS2010 SP1和WebDevServer(不是IIS Express)創建了一個新的MVC3項目,以驗證MVC解決方案模板中是否存在該錯誤。然後我將服務器切換到IIS Express,清理解決方案以確保它是全新的構建,並且錯誤**沒有發生。 – recalde 2011-03-22 14:49:39
那麼,正如我在我的較長文章中所說的,我的* bet *是這是PreApplicationStart + WebDev服務器+動態HttpModule註冊的問題。無論哪種方式,似乎這起源於Webdev的服務器,所以生產安全... – Linkgoron 2011-03-22 15:00:37