1. Stephen Drew
  2. PowerScript Migrator
  3. Tuesday, 18 June 2024 08:54 AM UTC

Hello,

I've been playing around with the migrator and generated an ASP.NET Core project with models, controllers and services.

However, when I try and run the app, I get the following error:

System.InvalidOperationException: Route exceeds the maximum number of allowed segments of 28 and is unable to be processed.

 

Is there a way to use query parameters instead of adding route segments for each parameter on the controllers?

 

[HttpGet("{par_nuac}/{par_coac}/{par_noabac}/{par_cola}/....etc")]

Thanks,

Stephen

Stephen Drew Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2024 15:49 PM UTC
  2. PowerScript Migrator
  3. # 1

Yes scaffolding service & controller from model.

Comment
There are no comments made yet.
Stephen Drew Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2024 15:16 PM UTC
  2. PowerScript Migrator
  3. # 2

Thanks for the quick reply Francisco!

 

Unfortunately I have over 1,500 of these.  I'll see if I can do this for just the ones that are broken, but given I'm doing iterative experimentation with the migration, this could become rather laborious.

Comment
  1. Francisco Martinez @Appeon
  2. Tuesday, 18 June 2024 15:42 PM UTC
How are you generating the controllers? Are you using the scaffolding tools?
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2024 14:51 PM UTC
  2. PowerScript Migrator
  3. # 3

Hi Stephen,

 

Instead of using route binding you could try using query binding:

[HttpGet()]
public ActionResult YourEndpoint(
    [FromQuery] string par_nuac,
    [FromQuery] string par_coac,
    [FromQuery] string par_noabac
    /* ... etc*/) {
}

 

I'm just writing this from memory, so I can't guarantee 100% that it works.
Also, I'm not sure if there's a limit to the number of parameter that can be bound this way.

You could also try model binding  and work with a C# object instead of over 28 parameters.

 

Regards,
Francisco

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.