Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make Web API using Asp.Net Web API 2 but getting HTTP Error 500.19 - Internal Server Error:
Following is my code:

What I have tried:

// Api Controller
public class EmployeeController : ApiController
    {
        EmployeeBusiness employeeBusiness = new EmployeeBusiness();
        public List<EmployeeModel> GetAllEmployee()
        {
            var employeeData = employeeBusiness.GetAllEmployee();
            return employeeData;
        }
    }


// Business Logic
public class EmployeeBusiness
    {
        CampaignAPIEntities dbcontext = new CampaignAPIEntities();

        private List<EmployeeModel> employeeData = new List<EmployeeModel>();
        EmployeeModel employeeModel = new EmployeeModel();
        public List<EmployeeModel> GetAllEmployee()
        {
            //employeeData = new List<EmployeeModel>();
            var _employee = dbcontext.Employees.Select(e => e);
            foreach (var item in _employee)
            {
                employeeModel.ID = item.ID;
                employeeModel.Name = item.Name;
                employeeModel.PhoneNumber = item.PhoneNo;
                employeeModel.DeviceID = item.DeviceID;
                employeeModel.Status = item.Status;

                //-- Adding model to list --
                employeeData.Add(employeeModel);
            }
            return employeeData;
        }
    }
Posted
Comments
Richard Deeming 1-Jun-17 10:29am    
There's a problem with your web.config file:
"HTTP Error 500.19" error when you open an IIS 7.0 Webpage[^]

Try making the request from a browser running on the server; you should get a much more detailed error message, which will tell you exactly what the problem is.
Bit2 Developer 7-Jun-17 2:39am    
Thanks Richard, you are right.
there is a problem in web.config file

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900