HEAD请求status 500
来源:5-12 【应用】使用http的HEAD请求

慕田峪0356378
2020-08-01
我的这个action
[HttpHead]
[HttpGet]
public IActionResult GetTouristRoutes()
用GET 时status 是200
可是HEAD请求status 是500
大概哪里出错了?
谢谢
3回答
-
慕田峪0356378
提问者
2020-08-02
错误信息
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
FakeXieCheng.API.Controllers.TouristRoutesController.GetTouristRoutes (FakeXieCheng.API)
FakeXieCheng.API.Controllers.TouristRoutesController.GetTouristRouteById (FakeXieCheng.API)
如果在TouristRouteController中只给一个action(GetTouristRoutes) 加[HttpHead], 而不是同时加[HttpHead]给GetTouristRoutes 和GetTouristRouteById, 就没有错了。可是你同时加给两个iactions??
另外, 测试return NotFound(“我错了”)是因为我输入了错误的Id, 所以报错(invalid id)。
谢谢
312020-08-03 -
阿莱克斯刘
2020-08-02
只是这样描述看不出来问题,有没有错误信息?有的话贴出来看看。
00 -
慕田峪0356378
提问者
2020-08-01
对了, 在我的Postman 测试return NotFound(“我错了”)时, 也从来不显示“我错了”这句话, 只是空格
012020-08-02
相似问题