2015-11-13 47 views
1

在我的MVC應用程序,我有時會得到一個異常,如:UnobservedTaskException - 哪裏的任務來自

System.Net.WebException: The request was aborted: The request was canceled. 
    at System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state) 
    at System.Net.Http.HttpClientHandler.StartGettingRequestStream(RequestState state) 
    at System.Net.Http.HttpClientHandler.<>c__DisplayClass4.<PrepareAndStartContentUpload>b__0(Task task) 
    at System.Threading.Tasks.Task.Execute() 
    --- End of inner exception stack trace --- 

編輯 這裏是另一種我看到:

System.Exception: Unhandled Task Error ---> System.NullReferenceException: Object reference not set to an instance of an object. 
    at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) 
    at System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(Exception error) 
    at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) 
    at System.Threading.Tasks.Task.Execute() 
    --- End of inner exception stack trace --- 

這裏就是我請參閱事件日誌,但時間或數量並不完全相關。

A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 1205. 

An TLS 1.2 connection request was received from a remote client application, but none of the cipher suites supported by the client application are supported by the server. The SSL connection request has failed. 

/EDIT

有沒有一種方法來識別異常的源/位置或獲取有關異常來自何處的任何其他信息?編輯2 這是我看到的另一個。他們都與OnAsyncHandlerCompletion有關,但我不確定源是什麼。

System.Exception: Unhandled Task Error ---> System.NullReferenceException: Object reference not set to an instance of an object. 
at System.Web.HttpApplication.get_CurrentModuleContainer() 
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) 
at System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(Exception error) 
at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) 
at System.Threading.Tasks.Task.Execute() 
--- End of inner exception stack trace --- 

/EDIT 2

+0

使用像fiddler或wireshark這樣的嗅探器來獲取來自http的錯誤消息。您可以查看管理工具:事件查看器以獲取更多詳細信息。 – jdweng

+0

你不知道你的應用程序在哪裏發起http請求? –

+0

@jdweng Fiddler/wireshark會給出一些上下文,但我一直在尋找能夠幫助識別代碼位置的東西。 – dmarlow

回答

0

您可以訂閱TaskScheduler.UnobservedTaskException事件,也許得到關於異常的更多信息。

+0

這就是我目前從中得到例外的地方。我只是記錄它,並且很好奇它的起源,因爲它包含的信息很少。 – dmarlow