小编Ali*_*taz的帖子

“Route”是“Microsoft.AspNetCore.Components.RouteAttribute”和“Microsoft.AspNetCore.Mvc.RouteAttribute”之间的不明确引用

我正在使用属性路由。我需要两个程序集参考。我已经尝试过,但对我不起作用。有谁知道如何解决这一问题?这是我的控制器代码:命名空间

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Task1CRUD.Repository;
using Task1CRUD.Model;

namespace Task1CRUD.Controllers
{

    [Route("api/[Controller]")]
    [ApiController]
    public class CustomerController:Controller
    {
            private readonly ICustomerRepository _customerRep;
            public CustomerController(ICustomerRepository customerRepository)
            {
                _customerRep = customerRepository;
            }

            // GET api/values
            [HttpGet("")]
            public async Task<List<Customer>> GetCustomers()
            {
                return await _customerRep.GetCustomers();
            }

    }
}
Run Code Online (Sandbox Code Playgroud)

.net routes .net-core asp.net-core

5
推荐指数
1
解决办法
4110
查看次数

标签 统计

.net ×1

.net-core ×1

asp.net-core ×1

routes ×1