This is a strange issue I have noticed several times recently in different solutions and use cases, yet cannot reliably reproduce.
Basically I never get a response to the request when the reponse includes an object to be serialized. I can see the request, and if I set a breakpoint in the controller I can follow execution through to returning the response, but the response never arrives at the browser.
In task manager I can see that IIS Worker Process runs around 32% CPU load until I force it to close.
As mentioned I have noticed this issue across several solutions with various release and pre-release versions of Entity Framework and Web API 2. It seems very strange, and if I were to take a guess it would have something to do with the serialization, but that's pure speculation (the problem goes away if I don't return the object, but e.g. just a HttpResponseMessage without content).
I'm working on Windows 8.1, VS 2013 Update 1, using EF on LocalDb. I'm happy to provide additional information, if you can direct me where to look?
Comments: I don't think that's the issue here, as I'm not using async methods unless they're scaffolded in (I know I should be - but development first! ). Also, the problem goes away if I iterate over the results to create a new List<T> and return that. Some code to illustrate further: public class CurriculaController : ApiController { private LearniverseDbContext db = new LearniverseDbContext(); // GET api/Curricula public IEnumerable<Curriculum> GetCurricula(string term = "") { var data = db.Curricula.Include("CurriculumItems").Include("Subject").AsQueryable(); if (!string.IsNullOrEmpty(term)) { data = data.Where(x => x.Name.Contains(term) || x.CurriculumItems.Any(y=>y.Name.Contains(term)) || x.Subject.Name.Contains(term)); } List<Curriculum> results = new List<Curriculum>(); foreach (var item in data) { results.Add(new Curriculum { Name = item.Name, Description = item.Description, CurriculumId = item.CurriculumId }); } return results; } } If I skip the foreach loop and return the data object it fails. The example above will work, and return a result, as long as I'm only populating some of the properties for the Curriculum object, as seen in the foreach loop. If I add the whole entity like so: results.Add( item ); ...The controller returns, but the worker process hangs and the response never makes it to the browser (aka "The issue"). I have another theory that the problem can be caused by weird circular references in the data, perhaps some data is not correctly related, but shouldn't I at the very least get an exception on that? Also, since I've experienced it on different models/dbs/solutions it can't be that wild a conincidence? I have the JSON serializer set to ignore (Newtonsoft.Json.ReferenceLoopHandling.Ignore). Bonus info: the data volume in this development scenario is tiny - 2 or 3 records returned, and a total db size of 4Mb. If I leave the IIS Express Worker Process running at 33% CPU it continues to increase memory consumption until it reaches about 1,3GB and dies.
Basically I never get a response to the request when the reponse includes an object to be serialized. I can see the request, and if I set a breakpoint in the controller I can follow execution through to returning the response, but the response never arrives at the browser.
In task manager I can see that IIS Worker Process runs around 32% CPU load until I force it to close.
As mentioned I have noticed this issue across several solutions with various release and pre-release versions of Entity Framework and Web API 2. It seems very strange, and if I were to take a guess it would have something to do with the serialization, but that's pure speculation (the problem goes away if I don't return the object, but e.g. just a HttpResponseMessage without content).
I'm working on Windows 8.1, VS 2013 Update 1, using EF on LocalDb. I'm happy to provide additional information, if you can direct me where to look?
Comments: I don't think that's the issue here, as I'm not using async methods unless they're scaffolded in (I know I should be - but development first! ). Also, the problem goes away if I iterate over the results to create a new List<T> and return that. Some code to illustrate further: public class CurriculaController : ApiController { private LearniverseDbContext db = new LearniverseDbContext(); // GET api/Curricula public IEnumerable<Curriculum> GetCurricula(string term = "") { var data = db.Curricula.Include("CurriculumItems").Include("Subject").AsQueryable(); if (!string.IsNullOrEmpty(term)) { data = data.Where(x => x.Name.Contains(term) || x.CurriculumItems.Any(y=>y.Name.Contains(term)) || x.Subject.Name.Contains(term)); } List<Curriculum> results = new List<Curriculum>(); foreach (var item in data) { results.Add(new Curriculum { Name = item.Name, Description = item.Description, CurriculumId = item.CurriculumId }); } return results; } } If I skip the foreach loop and return the data object it fails. The example above will work, and return a result, as long as I'm only populating some of the properties for the Curriculum object, as seen in the foreach loop. If I add the whole entity like so: results.Add( item ); ...The controller returns, but the worker process hangs and the response never makes it to the browser (aka "The issue"). I have another theory that the problem can be caused by weird circular references in the data, perhaps some data is not correctly related, but shouldn't I at the very least get an exception on that? Also, since I've experienced it on different models/dbs/solutions it can't be that wild a conincidence? I have the JSON serializer set to ignore (Newtonsoft.Json.ReferenceLoopHandling.Ignore). Bonus info: the data volume in this development scenario is tiny - 2 or 3 records returned, and a total db size of 4Mb. If I leave the IIS Express Worker Process running at 33% CPU it continues to increase memory consumption until it reaches about 1,3GB and dies.