I have an OData service that is implemented with several MVC controllers using ODataController. I am having an issue with all but one of the controllers, where an Internal 500 error is being returned with nothing of help after my return statement:
/// <summary><see cref="ODataController" /> reacting to queries relating to <see cref="Contract" /></summary>
[CustomExceptionFilter]
public class ContractsController : ODataController
{
// GET: odata/Contracts
[EnableQuery]
public IQueryable<Contract> GetContracts()
{
return DataAccess.GetContracts();
}
... other methods
}
/// <summary>Single point of reference to access data</summary>
public static class DataAccess
{
/// <summary>Gets the queryable collection of <see cref="ContractCoverageDetail" /></summary>
/// <returns>The queryable collection of <see cref="ContractCoverageDetail" /></returns>
public static IQueryable<Contract> GetContracts()
{
IQueryable<Contract> results = null;
using (EntityFrameworkContext context = new EntityFrameworkContext())
results = context.Contracts.ToArray().AsQueryable();
return results;
}
}
Another controller using the same DataAccess class returns data just fine. All that is being returned for each other controller is:
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code/>
<m:message xml:lang="en-US">An error has occurred.</m:message>
</m:error>
The error appears to be raised after my return statement, and if I step through after the return (F10), I hit each individual { get; } property on the returned entity of the collection, after which a result with the above error is returned to the browser. I can't get actual error information (innererror) to appear for the life of me, and it's odd that one controller is working, while the remainder fail without any detail.
Does anyone have an Idea for what might be causing this, or how to turn on the error detail after the return statement?
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
in the global.asax.cs does not help, nor does either of the following in web.config:
<system.web>
<customErrors allowNestedErrors="true" mode="On" />
</system.web>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
Any idea how I can get to the actual exception being raised?
Here's the simple guide about how to debug the Web API OData and ODL lib.