Open Closed

Route error after upgrading to 8.0.2 #6531


User avatar
0
ddelamare created
  • ABP Framework version: 8.0.2
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: RoutePatternException: The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value.

Exception Route Pattern that fails: api/app//{id}

Microsoft.AspNetCore.Routing.Patterns.RoutePatternException
  HResult=0x80131500
  Message=The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value.
  Source=Microsoft.AspNetCore.Routing
  StackTrace:
   at Microsoft.AspNetCore.Routing.Patterns.RoutePatternParser.Parse(String pattern)
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointFactory.AddEndpoints(List`1 endpoints, HashSet`1 routeNames, ActionDescriptor action, IReadOnlyList`1 routes, IReadOnlyList`1 conventions, IReadOnlyList`1 groupConventions, IReadOnlyList`1 finallyConventions, IReadOnlyList`1 groupFinallyConventions, Boolean createInertEndpoints, RoutePattern groupPrefix)
   at Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource.CreateEndpoints(RoutePattern groupPrefix, IReadOnlyList`1 actions, IReadOnlyList`1 conventions, IReadOnlyList`1 groupConventions, IReadOnlyList`1 finallyConventions, IReadOnlyList`1 groupFinallyConventions)
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.UpdateEndpoints()
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Initialize()
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.GetChangeToken()
   at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateChangeTokenUnsynchronized(Boolean collectionChanged)
   at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureChangeTokenInitialized()
   at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
   at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.get_Endpoints()
   at TOG.Program.<>c.<Main>b__0_4(EndpointDataSource es) in C:\Users\DanielDelamare\source\repos\TOG2\src\TOG.HttpApi.Host\Program.cs:line 92
  • Steps to reproduce the issue: This error occurs when the application API is started and did not occur prior to the upgrade.

We have a controller that has a route attribute of "api/app" and is a subclass of AbpController. I checked if we defined any similar routes in our code, but there wasn't anything that could be a match. This was not happening prior to the upgrade and there have been no changes outside of the ones required to upgrade.


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    api/app//{id}

    It should be api/app/{id}

    - api/app//{id}
    + api/app/{id}
    

    Can you share your controller code?

    Can you reproduce this in a new 8.x template project?

  • User Avatar
    0
    ddelamare created

    I am aware of what the route should be, but the issue is that we do not have that route specified in our controller. I attempted to run the 8.x template project but it fails out of the box.

    Here are all of the public methods in our controller

    [Route("api/app")]
    public class AppController : AbpController
    
    [HttpGet]
    [Route("manifest.webmanifest")]
    public async Task Manifest()
    
    [HttpGet]
    [Route("asset/{name}")]
    public async Task Asset(string name)
    
    [HttpGet]
    [Route("seo/asset/{tenantId}/{name}")]
    public async Task SeoAsset(Guid tenantId, string name)
    
  • User Avatar
    0
    ddelamare created

    Note that the error persists after removing the AppController class from the project.

  • User Avatar
    0
    ddelamare created

    I have resolved the issue. It was caused by our service called IntegrationAppService which was generating bad routes in version 8.0.2. After renaming the class to IntegrationsAppService, it worked correctly. This leads me to believe that there is some conflict in the names with the new ABP version.

    For future reference, I used this code in the Program.cs of the API host right before the app.RunAsync() call to figure out the issue.

    /*

    • Uncomment this snippet to have it throw an exception when there's an invalid route. Then data can be
    • extracted from the exception to find the pattern of the broken route. var endpointSources = builder.Services.GetRequiredService<IEnumerable<EndpointDataSource>>(); // This call will throw an execption for invalid routes. var endpoints = endpointSources.SelectMany(es => es.Endpoints); */

    /*

    • Running this in the immediates window while having a debugger breaking before the exception will list
    • all of the routes with invalid patterns.

    var problem = ((Microsoft.AspNetCore.Routing.CompositeEndpointDataSource)endpointSources.First()).DataSources.First(); var actions = ((Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource)problem)._actions.ActionDescriptors; actions.Items.Where(x => x.Properties.Count == 1 && x.AttributeRouteInfo.Template.Contains("//")) */

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp/issues/18812#issuecomment-1899998048

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38