.NET Core3.0でWebAPIアプリケーションを実行しているときに、以下のエラーが発生します。属性ルーティングを実装し、statup.csのConfigureメソッドで以下のコードを使用しました
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
エラー:
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
System.ArgumentException: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character. (Parameter 'routeTemplate')
---> Microsoft.AspNetCore.Routing.Patterns.RoutePatternException: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character.
at Microsoft.AspNetCore.Routing.Patterns.RoutePatternParser.Parse(String pattern)
at Microsoft.AspNetCore.Routing.Patterns.RoutePatternFactory.Parse(String pattern)
at Microsoft.AspNetCore.Routing.Template.TemplateParser.Parse(String routeTemplate)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Routing.Template.TemplateParser.Parse(String routeTemplate)
at Microsoft.AspNetCore.Mvc.ApplicationModels.InferParameterBindingInfoConvention.ParameterExistsInAnyRoute(ActionModel action, String parameterName)
at Microsoft.AspNetCore.Mvc.ApplicationModels.InferParameterBindingInfoConvention.InferBindingSourceForParameter(ParameterModel parameter)
ありがとう!
私はこれを解決しました。属性ルーティングのHttpアクションの1つに終了「}」を追加するのを忘れました。
[HttpPost("{id}/like/{recipientId")]
ご覧のとおり、recipientIdの後に最後の「}」がありません。エラーは完全に誤解を招くと思います。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加