无法在我的第一个Web API中加载类型'WebApi.WebApiApplication'

时间:2019-02-16 19:13:48

标签: asp.net-web-api2

我写了我的第一个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);
        }
    }
}

在测试过程中(使用http://localhost:51855/api/Person/21),出现以下错误:

解析器错误消息:无法加载类型'WebApi.WebApiApplication'。

源错误:

第1行:<%@ Application Codebehind =“ Global.asax.cs” Inherits =“ WebApi.WebApiApplication” Language =“ C#”%>

0 个答案:

没有答案