我需要在OData服务控制器上公开常规服务方法。我的方法在运行时被正确选取,并且在我可以调试时执行正常,但是浏览器获得了406状态代码而没有响应主体。这是简化的代码:
[RoutePrefix("odata/contracts")]
public class ContractsController : EntitySetController<Contract, int>
{
private readonly IDataService dataService;
/// <summary>
///
/// </summary>
/// <param name="dataService"></param>
public ContractsController(IDataService dataService)
{
this.dataService = dataService;
}
[Route("WithItem")]
[HttpGet]
public IEnumerable<Contract> GetContractsByItem(string catalogNumber, string vendorName)
{
var result = dataService.GetContractsWithItem(catalogNumber, vendorName).ToList();
return result;
}
}
当我在Chrome或Fiddler(http://myserver/SoaRefImplOData/odata/contracts/WithItem?catalogNumber=abc&vendorName=3M
)中请求以下网址时,我获得了406状态代码。
那些不应该与OData控制器混合的常规Web Api方法也是如此?我正在使用Web Api 2.1。非常感谢提前!