I see there are many people struggling with this same issue, but none seems to lead me in the right direction - Perhaps I dont understand correctly, or my situation is just a little different - I have created an MVC app that runs perfectly on my local, but once deployed, I get the following errors in the Console :
Failed to load resource: the server responded with a status of 404 (Not Found) : glyphicons-halflings-regular.woff2
Failed to load resource: the server responded with a status of 404 (Not Found) : /api/notifications
Failed to load resource: the server responded with a status of 500 (Internal Server Error) : BudgetingTool/Account/UserDetails?searchTerm=Peter+Pan&_=1506510511716
The last one is the most important as this is used to return data. Its code is as follows:
public ActionResult UserDetails(string searchTerm = null)
{
var data = UserManager.Users.FirstOrDefault(r => (r.FirstName + " " + r.LastName) == searchTerm);
IEnumerable<SelectListItem> rolesList = null;
IEnumerable<SelectListItem> organisationList = null;
Organisation organisation = null;
Department department = null;
if (data != null)
{
var userOrganisations = _organisationRepo.GetUserAssignedOrganisation(data.Id);
organisation = _repository.FindOrganisationById(data.OrganisationId);
department = _departmentRepo.FindDepartmentById(organisation.DepartmentId);
rolesList = ShowAllowedRoles(data.Id);
organisationList =
_repository.GetOrganisationsInHierarchyOrder(0,0,0).Select(r => new SelectListItem
{
Selected = userOrganisations.Any(x => x.OrganisationId == r.OrganisationId) ? true : false,
Text = r.Name,
Value = r.OrganisationId.ToString()
});
//SelectedOrganisations = OrganisationList.Where(x => x.Selected == true).ToList().Select(r=> new List<string>{ r.Value});
}
else
{
organisationList = _repository.GetOrganisationsInHierarchyOrder(0, 0, 0).GroupBy(m => m.Name).Select(y => y.First()).Select(r => new SelectListItem
{
Selected = false,
Text = r.Name,
Value = r.OrganisationId.ToString()
});
rolesList = GetRolesList();
}
var model = new UpdateUserInfoVM
{
Id = data == null ? string.Empty : data.Id,
FirstName = data == null ? string.Empty : data.FirstName,
LastName = data == null ? string.Empty : data.LastName,
Email = data == null ? string.Empty : data.Email,
Allowbudgetdeletion = data?.Allowbudgetdeletion ?? false,
LockoutEnabled = data?.LockoutEnabled ?? false,
//OrganisationId = data == null ? string.Empty : data.OrganisationId,
OrganisationId = data?.OrganisationId ?? 0,
Organisations = organisationList,
Roles = rolesList,
AccessFailedCount = data?.AccessFailedCount ?? 0,
LockoutEndDateUtc = data?.LockoutEndDateUtc,
AllowEditing = data.AllowEditing,
DistrictOrUrban = data?.DistrictOrUrban,
departmentId = organisation.DepartmentId,
DepartmentType = department.Name
//SelectedOrganisations = SelectedOrganisations
};
return PartialView("_ShowUserInfo", model);
//return Request.IsAjaxRequest() ? PartialView("_ShowUserInfo", model) : PartialView("_ShowUserInfo", model);
}
When I click on the link for the error in the console, this is what displays(as if there is no value passed through ???
Server Error in '/BudgetingTool' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
I just dont understand how it can work so perfectly on my local, but not when published and then deployed to a remote server.
The folder is a virtual directory and the folder that contains the projects files is shared with "Everyone" and "IIS_IUSR" - Both have read/write permission.
What are the most general things that one can look for ? Im sure its something so simple, but just can not find out what it is :(
Any help in the right direction would be of great help.
Thanks!