在 .NET Core 3 中获取 Microsoft.AspNetCore.Hosting.Diagnostics[6] 应用程序启动异常
Getting Microsoft.AspNetCore.Hosting.Diagnostics[6] Application startup exception in .NET Core 3
使用 .NET Core 3.0 的 运行 Web API 应用程序时出现以下错误。我已经实现了属性路由并在 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 操作添加结尾的“}”。
[HttpPost("{id}/like/{recipientId")]
如您所见,recipientId 后缺少结尾的“}”。我认为这个错误完全是误导。
使用 .NET Core 3.0 的 运行 Web API 应用程序时出现以下错误。我已经实现了属性路由并在 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 操作添加结尾的“}”。
[HttpPost("{id}/like/{recipientId")]
如您所见,recipientId 后缺少结尾的“}”。我认为这个错误完全是误导。