【发布时间】:2021-04-09 21:23:00
【问题描述】:
我正在使用属性路由。我需要两个程序集参考。我试过了,但没有为我工作。有谁知道如何解决这一问题?这是我的控制器代码: 命名空间
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();
}
}
}
【问题讨论】:
标签: .net asp.net-core .net-core routes