IoTSharp / SilkierQuartz

SilkierQuartz can host jobs using HostService and Provide a web management tools for Quartz !
http://sq.iotsharp.io/
MIT License
357 stars 71 forks source link

RoutePatternException occurs inside of ApplicationBuilderExtensions.UseSilkierQuartz method (a project with WebAssembly.Server) #146

Open mamift opened 1 year ago

mamift commented 1 year ago

Hello,

I'm getting an RoutePatternException when invoking the ApplicationBuilderExtensions.UseSilkierQuartz method inside a WebAssembly.Server project.

The full exception trace is:

Microsoft.AspNetCore.Routing.RouteCreationException
  HResult=0x80131500
  Message=An error occurred while creating the route with name 'SilkierQuartz' and pattern '//{controller=Scheduler}/{action=Index}'.
  Source=Microsoft.AspNetCore.Mvc.Core
  StackTrace:
   at Microsoft.AspNetCore.Mvc.Routing.ConventionalRouteEntry..ctor(String routeName, String pattern, RouteValueDictionary defaults, IDictionary`2 constraints, RouteValueDictionary dataTokens, Int32 order, List`1 conventions)
   at Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource.AddRoute(String routeName, String pattern, RouteValueDictionary defaults, IDictionary`2 constraints, RouteValueDictionary dataTokens)
   at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapControllerRoute(IEndpointRouteBuilder endpoints, String name, String pattern, Object defaults, Object constraints, Object dataTokens)
   at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.<>c__DisplayClass4_0.<UseSilkierQuartz>b__1(IEndpointRouteBuilder endpoints)
   at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
   at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseSilkierQuartz(IApplicationBuilder app, Action`1 configure)
   at DmsImporter.Server.Program.<ConfigureAppAsync>d__16.MoveNext() in C:\Users\mmiftah\source\Tests\DmsImporter\DmsImporter\Server\Program.cs:line 200

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
RoutePatternException: The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value.

I think the issue is here at this line inside ApplicationBuilderExtensions.cs:

endpoints.MapControllerRoute(nameof(SilkierQuartz), $"{options.VirtualPathRoot}/{{controller=Scheduler}}/{{action=Index}}");
endpoints.MapControllerRoute($"{nameof(SilkierQuartz)}Authenticate", $"{options.VirtualPathRoot}/{{controller=Authenticate}}/{{action=Login}}");

By default options.VirtualPathRoot is always '/', so the string template is pre-prending '/' twice.

Seems to only happen when using WebAssembly.Server in the same project.

IgorPrischepa commented 1 year ago

I encountered the same error in an ASP.NET Core project.

SilkierQuartz Version: 5.0.356

image

huangdongqin commented 10 months ago

app.UseSilkierQuartz((services) => services.Options.VirtualPathRoot = "/quartz") ; it can aviod error.but can't access the page.....