Reputation: 1029
I am getting Error 5000 on server side with Patterns.RoutePatternException and message:
Microsoft.AspNetCore.Routing.Patterns.RoutePatternException: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character.
I am getting the follow exception on the serverside;
09/15/2020 21:06:17 -05:00 Error An unhandled exception has occurred while executing the request. 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.Mvc.Routing.ActionEndpointFactory.AddEndpoints(List
1 endpoints, HashSet
1 routeNames, ActionDescriptor action, IReadOnlyList1 routes, IReadOnlyList
1 conventions, Boolean createInertEndpoints) at Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource.CreateEndpoints(IReadOnlyList1 actions, IReadOnlyList
1 conventions) at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.UpdateEndpoints() at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Initialize()
This is my second app with Blazor/Core ASP 3.1 and I tried to copy the first working one. On the client side the code gets to StartAsync()
Log.Warning("top of start service");
connection = new HubConnectionBuilder()
.WithUrl(url)
.Build();
Log.Warning("after connect in start service");
connection.Closed += async (error) =>
{
await Task.Delay(new Random().Next(0, 5) * 1000);
await connection.StartAsync();
};
connection.Reconnecting += error =>
{
Log.Error("Connection Lost attempting to reconnect: {@error}", error);
// Notify users the connection was lost and the client is reconnecting.
// Start queuing or dropping messages.
return Task.CompletedTask;
};
try
{
Log.Warning("before start async");
await connection.StartAsync();
Log.Warning("after start async");
Program.cs
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(config)
.CreateLogger();
try
{
CommandLine.Parser.Default.ParseArguments<Options>(args)
.WithParsed(RunOptions)
.WithNotParsed(HandleParseError);
BuildWebHost(args).Build().Run();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public static IHostBuilder BuildWebHost(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
_ = webBuilder.UseUrls("http://*:8080");
}).UseSerilog();
Startup.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(o => o.AddPolicy("CorsPolicy", builder =>
{
builder
//.WithOrigins("http://localhost:44322")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowAnyOrigin();
}));
services.AddSignalR();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
//app.UseStatusCodePagesWithReExecute("/Error");
app.UseDeveloperExceptionPage();
}
else
{
app.UseStatusCodePagesWithReExecute("/Error");
//app.UseHsts();
}
app.UseCors("CorsPolicy");
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseRouting();
//var hubConfiguration = new HubConfiguration();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<ShowsHub.BlazingShowsHub>("/shows");
endpoints.MapDefaultControllerRoute();
});
}
Suggestions?
Upvotes: 1
Views: 734
Reputation: 4022
Microsoft.AspNetCore.Routing.Patterns.RoutePatternException: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character.
From the RoutePatternException
you post, we can see it must be something wrong with the route template of controller. Please check your route template like [Route("api/users/{userId/login")]
missing }
.
Upvotes: 1