【发布时间】:2017-07-25 16:12:54
【问题描述】:
我希望从我的 ASP.NET Web API 获得响应,该 API 以对象类型 Product 进行响应。
但是,当我尝试通过 Postman 获得响应时,它总是返回给我
500 内部服务器错误。
以下是我的代码,提前感谢您提供的任何帮助:
[ResponseType(typeof(Product))]
[Route("webapi/products/{productname}")]
public async Task<IHttpActionResult> GetProduct(string productname)
{
var product = (Product)db.Products.Where(t => t.name.Contains(productname));
//^^^^^^this seems to be the problem^^^^^^^//
if (product == null)
{
return NotFound();
}
return Ok(product);
}
【问题讨论】:
标签: c# asp.net-mvc linq asp.net-web-api get