刚接触.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);
}
}
我可以用以下URL调用API:
http://localhost:51375/api/customer/8172858817
我在GET方法中打了断点,但是Id总是为零。我无法让该方法读取从URL传递的值。
有什么建议吗?
2147483647
。您的值太大了,请改用long
。 - Nkosi