响应包括堆栈跟踪,即使 DebugMode 和 WriteErrorsToResponse 被禁用
Response includes stacktrace even though DebugMode and WriteErrorsToResponse are disabled
我是 运行 一个在最新版本的 ServiceStack (5.6.0) 上自托管的 API。
我很难在请求处理管道的早期处理异常。更具体地说,当请求包含 |
个字符时。 API 将始终 return 带有 stackTrace 的完整错误响应。即使在禁用 DebugMode
和 WriteErrorsToResponse
的发布版本中。
通常我没有问题,因为大多数问题都是在具有自定义错误响应 DTO 的自定义 ServiceRunner 中处理的。但是这个错误发生在调用ServiceRunner之前。
如何禁用 stackTrace?是否可以用自定义响应替换错误响应?
这是我在点击时收到的响应对象,例如http://localhost:80/*|?
{
"responseStatus": {
"errorCode": "ArgumentException",
"message": "Illegal characters in path.",
"stackTrace": " at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)\r\n at System.IO.Path.InternalCombine(String path1, String path2)\r\n at System.IO.FileSystemEnumerableIterator`1.GetFullSearchString(String fullPath, String searchPattern)\r\n at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)\r\n at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)\r\n at ServiceStack.VirtualPath.FileSystemVirtualDirectory.GetFileFromBackingDirectoryOrDefault(String fName)\r\n at ServiceStack.VirtualPath.AbstractVirtualPathProviderBase.GetFile(String virtualPath)\r\n at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()\r\n at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)\r\n at ServiceStack.Host.HttpListener.ListenerRequest.GetFile()\r\n at ServiceStack.Host.HttpListener.ListenerRequest.get_IsFile()\r\n at ServiceStack.HttpHandlerFactory.GetHandlerForPathInfo(IHttpRequest httpReq, String filePath)\r\n at ServiceStack.HttpHandlerFactory.GetHandler(IHttpRequest httpReq)\r\n at ServiceStack.AppHostHttpListenerBase.<ProcessRequestAsync>d__8.MoveNext()",
"errors": null,
"meta": null
}
}
现在应从 this commit 解决此问题,在 Config.DebugMode = false
.
时它将不再显示 HTTP 侦听器异常的 StackTraces
此更改适用于 v5.6.1+,即现在 available on MyGet。
我是 运行 一个在最新版本的 ServiceStack (5.6.0) 上自托管的 API。
我很难在请求处理管道的早期处理异常。更具体地说,当请求包含 |
个字符时。 API 将始终 return 带有 stackTrace 的完整错误响应。即使在禁用 DebugMode
和 WriteErrorsToResponse
的发布版本中。
通常我没有问题,因为大多数问题都是在具有自定义错误响应 DTO 的自定义 ServiceRunner 中处理的。但是这个错误发生在调用ServiceRunner之前。
如何禁用 stackTrace?是否可以用自定义响应替换错误响应?
这是我在点击时收到的响应对象,例如http://localhost:80/*|?
{
"responseStatus": {
"errorCode": "ArgumentException",
"message": "Illegal characters in path.",
"stackTrace": " at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)\r\n at System.IO.Path.InternalCombine(String path1, String path2)\r\n at System.IO.FileSystemEnumerableIterator`1.GetFullSearchString(String fullPath, String searchPattern)\r\n at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)\r\n at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)\r\n at ServiceStack.VirtualPath.FileSystemVirtualDirectory.GetFileFromBackingDirectoryOrDefault(String fName)\r\n at ServiceStack.VirtualPath.AbstractVirtualPathProviderBase.GetFile(String virtualPath)\r\n at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()\r\n at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)\r\n at ServiceStack.Host.HttpListener.ListenerRequest.GetFile()\r\n at ServiceStack.Host.HttpListener.ListenerRequest.get_IsFile()\r\n at ServiceStack.HttpHandlerFactory.GetHandlerForPathInfo(IHttpRequest httpReq, String filePath)\r\n at ServiceStack.HttpHandlerFactory.GetHandler(IHttpRequest httpReq)\r\n at ServiceStack.AppHostHttpListenerBase.<ProcessRequestAsync>d__8.MoveNext()",
"errors": null,
"meta": null
}
}
现在应从 this commit 解决此问题,在 Config.DebugMode = false
.
此更改适用于 v5.6.1+,即现在 available on MyGet。