On my local server it returns json but when I publish it to remote server. I get 500 internal server error.
I can't run the hosted site in debug mode, on local host it seems fine. The remote server is IIS8.5 X-AspNet-Version: 4.0.30319 and my local IIS is iis 8
The html response is 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.
Api Controller
public class loginapiController : ApiController
{
[System.Web.Http.HttpGet]
public UserProjects UserProjects(int id)
{
return new UserProjects(id);
}
}
public class UserProjects
{
public IEnumerable<Project> Projects = new List<Project>();
public List<Project> ExistingUserProjects = new List<Project>();
public int UserId { get; set; }
public UserProjects(int userId)
{
UserId = userId;
var context = new AuditConnection();
var existingProjectIds = context.UserProjects.Where(up => up.UserId == userId).Select(p => p.ProjectId);
foreach (var id in existingProjectIds)
{
var project = context.Projects.Where(p => p.ProjectId == id).First();
ExistingUserProjects.Add(project);
}
var proj = context.Projects.ToList();
Projects = proj.Except(ExistingUserProjects);
}
}
You can look at the exception using this link http://sentry.landsea.com.au/api/loginapi/UserProjects/4