ASP.NET Web API:非描述性 500 内部服务器错误 [英] ASP.NET Web API: Non-descriptive 500 Internal Server Error
问题描述
正如标题所说,从 GET 请求到 IQueryable 操作,我收到了 500 内部服务器错误.错误的正文是空的.该错误发生在我的操作返回结果之后.
As title says, I’ve got 500 Internal Server Error from GET request to an IQueryable action. The body of the error is empty. That error happens after my action returns result.
我使用 ASP.NET Web API RC.
I use ASP.NET Web API RC.
如何获得该错误的堆栈跟踪?
How can I get stack trace of that error?
推荐答案
发布 RC,此问题已修复,除了 500 内部服务器错误之外,您还将获得错误详细信息.(尽管此问题仅适用于 Web 主机方案).
Post RC, this issue was fixed and you will be getting error details also apart from the 500 Internal Server Error. (This issue is fixed for Web Host scenarios only though).
您可以执行以下操作以获取在格式化程序的 WriteToStream 方法期间可能发生的实际异常的详细信息.
You could do the following to get the details of the actual exception which might be occurring during a formatter's WriteToStream method.
ObjectContent<IEnumerable<Product>> responseContent = new ObjectContent<IEnumerable<Product>>(db.Products.Include(p => p.ProductSubcategory).AsEnumerable(), new XmlMediaTypeFormatter()); // change the formatters accordingly
MemoryStream ms = new MemoryStream();
// This line would cause the formatter's WriteToStream method to be invoked.
// Any exceptions during WriteToStream would be thrown as part of this call
responseContent.CopyToAsync(ms).Wait();
这篇关于ASP.NET Web API:非描述性 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!