I have a basic setup of web API 2 with some basic routing.
Below is the default route and message for inserts. When I call the message, the record is created perfectly in the database, but the call "CreatedAtRoute" returns message 500:
ExceptionMessage: "UrlHelper.Link must not return null." ExceptionType: "System.InvalidOperationException"
Why am I getting this error?
[RoutePrefix("api/casenotes")] public class CasenoteController : ApiController... // POST api/Casenote [Route("")] [ResponseType(typeof(client_admission_casenote))] public async Task<IHttpActionResult> Postclient_admission_casenote (client_admission_casenote client_admission_casenote) { Request.GetRequestContext().IncludeErrorDetail = true; if (!ModelState.IsValid) { return BadRequest(ModelState); } db.client_admission_casenote.Add(client_admission_casenote); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = client_admission_casenote.casenote_id }, client_admission_casenote); }
asp.net-web-api2
Aaron Lind Apr 14 '15 at 19:45 2015-04-14 19:45
source share