locked
error : Could not load type 'WebApi.WebApiApplication' in my first web api. RRS feed

  • Question

  • User-1548796982 posted

    hi

    I write my first web api.

    namespace WebApi.Controllers
    {
        public class PersonController : ApiController
        {
            public IEnumerable<CommonPerson> GetAllPersons()
            {
                 PersonRepository PersonRep = new PersonRepository();
                return PersonRep.SelectAll();   
            }
    
            public IHttpActionResult GetPerson(int id)
            {
                PersonRepository PersonRep = new PersonRepository();
                CommonPerson person = new CommonPerson();
                person=PersonRep.SelectByID(id);
    
                if (person == null)
                {
                    return NotFound();
                }
                return Ok(person);
            }
        }
    }
    

    During the test (with http://localhost:51855/api/Person/21), the following error is given:

    Parser Error Message: Could not load type 'WebApi.WebApiApplication'.

    Source Error:

    Line 1:  <%@ Application Codebehind="Global.asax.cs" Inherits="WebApi.WebApiApplication" Language="C#" %>
    

    Saturday, February 16, 2019 7:10 PM

All replies