Vote count: 0 I have some Web API server methods that include the following POST action. Without specifying the [Route()] directive, the response completes fine with CreatedAtRoute(). When setting the directive (with and without the tilde), then that method fails. Changing it to Created() makes it succeed. [HttpPost] [Route("~/api/ExamTaken")] [Authorize] [ResponseType(typeof(ExamTaken))] public async Task PostExamTaken(ExamTaken ExamTaken) { // ... db.ExamsTaken.Add(ExamTaken); await db.SaveChangesAsync(); // This line fails //retu CreatedAtRoute("DefaultApi", new { id = ExamTaken.Id }, ExamTaken); // This line succeeds retu Created(ExamTaken.Id.ToString(), ExamTaken); // ... } In all cases...
ادامه مطلب