.NET Core新手.
我究竟做错了什么?这是我的控制器
[Route("api/[controller]")]
public class customerController : Controller
{
// GET: api/values
//[HttpGet]
//public IEnumerable<string> Get()
//{
// return new string[] { "value1", "value2" };
//}
// GET api/values/5
[HttpGet("{id}")]
public customer Get(int id)
{
var repo = new customerRepository();
return repo.GetCustomerOnPhone(id);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用此URL调用API
http://localhost:51375/api/customer/8172858817
我在GET方法中遇到断点,但Id始终为零.我无法获取方法来读取从URL传递的值.
有什么建议?