2013-09-27 58 views
2

看起來只有請求dto,異常對象可在AppHost的ServiceExceptionHandler中使用。我需要訪問IHttpRequest對象,以便可以訪問Items集合並獲取我的請求上下文的元數據。ServiceStack:如何從我的AppHost中的ServiceExceptionHandler中獲取IHttpRequest對象?

+0

您可以使用ExceptionHandler處理程序,您可以在其中爲以下簽名提供'this.ExceptionHandler =(req,res,operationName,ex)=> {}',其中'ExceptionHandler'是一個'public delegate void HandleUncaughtExceptionDelegate( IHttpRequest httpReq,IHttpResponse httpRes,string operationName,Exception ex);' – nemesv

+0

捕獲與服務無關的異常。你是對的,它有我需要的參數,但它不適用於服務級別的異常。 – mariocatch

回答

4

同意。它目前不可用,但是I've just checked this into v3和主分支。在本週末發佈v3.9.64 +後,它將在NuGet上推出。

我通常不願意添加重大更改,但應該只將其本地化爲1個地方,因此它不應該太具有破壞性,因爲您已經描述訪問IHttpRequest是有用的。

+0

mythz,ServiceStack.Interfaces(在ServiceStack.Common中)看起來沒有正確的版本。它是1.0.0.0,而3.9.64版本中的所有其他程序集都是3.9.64.0 – mariocatch