ODataUnrecognizedPathException:在ASP.NET CORE中找不到段'x'的资源

时间:2017-07-13 07:30:59

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

我收到此错误:ODataUnrecognizedPathException:找不到段'sample'的资源。

控制器代码是这样的:

[Produces("application/json")]
    [Route("api/Sample")]
    public class SampleController : Controller
    {

        private readonly ISampleBusiness business;
        public SampleController(ISampleBusiness _business)
        {
            business = _business;
        }
        // GET: api/Sample
        [HttpGet]
        [EnableQuery]
        public async Task<IQueryable<ISGUserDTO>> Get()
        {
            var data = await business.GetAll();
            return data.Data;
        }

启动代码如下:

public void ConfigureServices(IServiceCollection services)
        {
services.AddOData<ISampleBusiness>(builder => builder.EntitySet<Business.Contracts.DTO.Infra.ISGUserDTO>("Sample"));

像这样配置:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseOData("api");

任何想法有什么不对?

0 个答案:

没有答案