2014-04-23 42 views
2

我有一個通過OWIN啓動類在IIS設置上運行的WebApi。從Visual Studio部署之後,幾個請求總是失敗。這個窗口只能持續幾秒鐘。之後一切都很好。如何在執行WebDeploy時防止失敗的請求?

我得到異常這樣的:

System.ArgumentException: The 'DelegatingHandler' list is invalid because the property 'InnerHandler' of 'CorsMessageHandler' is not null. 
Parameter name: handlers 
    at System.Net.Http.HttpClientFactory.CreatePipeline(HttpMessageHandler innerHandler, IEnumerable`1 handlers) 
    at System.Web.Http.HttpServer.Initialize() 
    at System.Web.Http.HttpServer.<EnsureInitialized>b__b() 
    at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) 
    at System.Web.Http.HttpServer.EnsureInitialized() 
    at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at System.Web.Http.Owin.HttpMessageHandlerAdapter.<InvokeCore>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) 
    at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

或:

System.ObjectDisposedException: Cannot access a disposed object. 
Object name: 'System.Web.Http.HttpServer'. 
    at System.Net.Http.DelegatingHandler.set_InnerHandler(HttpMessageHandler value) 
    at System.Web.Http.HttpServer.<EnsureInitialized>b__b() 
    at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) 
    at System.Web.Http.HttpServer.EnsureInitialized() 
    at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at System.Web.Http.Owin.HttpMessageHandlerAdapter.<InvokeCore>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) 
    at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

我記錄這些來自於IHttpModule.Init HttpApplicationContext.Error事件處理程序。他們沒有達到WebApi的IExceptionLogger。這些發生在我的啓動已經運行後(在這些例外之前出現在日誌中)。

我希望在部署時儘量減少失敗請求的數量。

我從哪裏開始?

回答

0

如果你不能忍受部署過程中的任何物體光點,你可能要考慮一個「藍/綠部署」的方法:

讓你的IIS站點下的2個獨立的應用程序 - 一個用於當前什麼是在生產,一個用於通過WebDeploy推送的登臺/甲板版本。 WebDeploy成功後,您可以將生產IIS應用程序指向此新文件夾。舊文件夾現在是一個短期備份,如果有任何事情發生,您可以將其重新轉換爲備份,之後可以將其重新用作下一次部署的登臺/備用。

當然,你可以自動化這個更多,但這是基本的想法。

相關問題