我有这个控制器:
using System.Web.Http;
using System.Web.OData;
public class InvRecipientAutoInvoiceController : ODataController
{
// GET: odata/InvRecipientAutoInvoice
[EnableQuery]
public IQueryable<Inv_RecipientAutoInvoice> GetInvRecipientAutoInvoice()
{
return db.Inv_RecipientAutoInvoice.Where(a=>a.CompanyNumber == CompanyNumber);
}
[AcceptVerbs("PATCH", "MERGE")]
public IHttpActionResult Patch([FromODataUri] int RecipientNumber , [FromODataUri] int RecipientType, Delta<Inv_RecipientAutoInvoice> patch)
{
// XXXX Some Update Code
}
}
GET 有效,我得到结果,甚至可以对它们进行排序。但是当我执行 PATCH 请求时,我收到 404 错误,PATCH 请求:
请求网址:http://localhost:61240/odata/InvRecipientAutoInvoice(RecipientNumber%3D443%2CRecipientType%3D400)
Request Method: PATCH
- 响应正文:
{ "error":{ "code":"","message":"没有找到与请求 URI 匹配的 HTTP 资源 ' http://localhost:61240/odata/InvRecipientAutoInvoice(RecipientNumber=443,RecipientType=400) ' .","innererror":{ "message":"在控制器 'InvRecipientAutoInvoice' 上找不到与请求匹配的操作。","type":"","stacktrace":"" } } }
- 请求正文:
{"InvoiceLine1Description":"32132"}
我在 ASP.net Web 项目(不是 MVC)中使用它,
寄存器是:
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: "odata",
model: builder.GetEdmModel());
我错过了什么?