Ok...this was easy once you see whats going on. In attribute routing you have to specify the Name of the route to retrieve the resource. So on my GET action it looks like this:
[Route("{sessionId}",Name="GetSession")]
[ResponseType(typeof(Session))]
public async Task<IHttpActionResult> Get(HttpRequestMessage request, int accountId, int siteId, Guid visitorId, Guid sessionId)
And then in the POST action change the CreatedAtRoute from:
return CreatedAtRoute("DefaultApi", new
{
controller: "session"
visitorId = session.VisitorId,
sessionId = session.SessionId
}, session);
To this:
return CreatedAtRoute("GetSession", new
{
visitorId = session.VisitorId,
sessionId = session.SessionId
}, session);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…