405(不允许的方法)错误web api ajax call

时间:2016-11-03 10:05:49

标签: c# asp.net-web-api

我正在尝试创建一个web api应用程序但我的ajax调用有问题(使用angularjs)。我的get方法没问题但是当我想调用getbyid方法时,它返回405(方法不允许)。

控制器:

public class BasicInformationRepository : IBasicInformationRepository
{
    private readonly PezhContext _context;

    public BasicInformationRepository(PezhContext context)
    {
        _context = context;
    }

    /// <summary>
    /// takes all SUBSYSTEMS
    /// </summary>
    /// <returns>SUBSYSTEMS</returns>
    public IEnumerable<BasicInformation> GetSubSystems()
    {
        return _context.BasicInformation.Where(a => a.BsiType == 1 && a.BsiParrentId == 0);
    }

    public IEnumerable<BasicInformation> GetSubMenuBySubSystem(int subSystemId)
    {
        return from bsi in _context.BasicInformation
            where (bsi.BsiParrentId == subSystemId && bsi.BsiType == 2)
            select bsi;
    }
}

0 个答案:

没有答案