【发布时间】:2018-03-07 03:58:16
【问题描述】:
嗨,我在 Windows 7 上使用 vs 2017 我正在关注 this 关于复数视线的教程:.net core 2 web api。 GET 方法工作正常。有内部服务器错误 500。我感谢任何人检测到此错误的来源。我正在使用 Postman / Fiddler 两者都给出相同的 500 错误:
[HttpPost("{cityid}/pointofinterest", Name = "GetPointOfInterest")]
public IActionResult CreatePointofInterest(int cityid, [FromBody]
PointofInterestForCreationtDto inputPointofinterest)
{
if (inputPointofinterest == null)
{
return BadRequest();
}
var theCity = (CitiesRepo.Current.Cities.FirstOrDefault(x => x.Id == cityid));
if (theCity == null)
{
return NotFound();
}
//get new id
var maxid= CitiesRepo.Current.Cities.SelectMany(
c => c.PointsOfInterest).Max(p => p.Id);
var postedPointofInterest = new PointOfInterestDto()
{
Id = ++maxid,
Name = inputPointofinterest.Name,
Description = inputPointofinterest.Description
};
theCity.PointsOfInterest.Add(postedPointofInterest);
return CreatedAtRoute("GetPointOfInterest",
new { CityId= cityid, id = postedPointofInterest.Id, postedPointofInterest });
}
【问题讨论】:
-
提示:使用预览标签来实际读取错误。
-
感谢这是错误:处理请求时发生未处理的异常。 AmbiguousActionException:匹配多个操作。以下操作匹配路线数据并满足所有约束: CitiesInfo.Api.Controllers.CitiesController.CreatePointofInterest (CitiesInfo.Api) CitiesInfo.Api.Controllers.PointofInterestController.CreatePointofInterest (CitiesInfo.Api) M
-
你是对的:我得到错误,有另一个具有相同路由和签名的方法
标签: asp.net-web-api asp.net-core-2.0