【发布时间】:2017-01-27 05:35:42
【问题描述】:
为了获得 404,我做错了什么?
我正在向我的控制器发出请求:
/// <category>Public Note operations</category>
/// <summary> Gets the public note for the specified entity. </summary>
/// <returns> Note matching unique NoteId identifier. </returns>
/// <example>
/// Sample URI handled by this method is:
/// <code>
/// http://localhost:5001/ooo360/api/v2/Note(4a872b89-f42e-e511-9419-00155d104c97)/attachment
/// </code>
/// </example>
[Route("{entityLogicalName}/({entityGuid:guid})/PublicNotes", Name = "GetPublicNotesForEntity")]
[HttpGet]
public IEnumerable<Annotation> GetPublicNotesForEntity(string entityLogicalName, Guid entityGuid)
{
// there's a breakpoint here that never even gets triggered
return this._PublicNoteService.Get(entityLogicalName, entityGuid);
}
一个请求的例子是:
http://localhost:5001/ooo360/api/v2/TroubleTicket(058A9570-D373-E511-9420-00155D10416C)/PublicNotes
我做错了什么?
【问题讨论】:
-
~ 你是否在 web api 配置中启用了属性路由? ~在
TroubleTicket和Guid - localhost:5001/ooo360/api/v2/TroubleTicket/… 之间不应该有一个/~ 你是否设置了正确的路由前缀以便ooo360/api/v2得到解决? -
非常感谢你发现这个愚蠢的错误,缺少斜线
标签: c# asp.net-web-api routes