的ASP.NET Web API:非描述500内部服务器错误 [英] ASP.NET Web API: Non-descriptive 500 Internal Server Error

查看:168
本文介绍了的ASP.NET Web API:非描述500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题所说,我已经得到了从GET请求500内部服务器错误为IQueryable行动。错误的身体是空的。我的行动返回结果之后发生错误。

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内部服务器错误得到错误的详细信息。 (这个问题是固定的虚拟主机方案只能虽然)。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆