-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Improvements over MapVerb and friends... #5295
Comments
Though we are not planning to add these extension methods to the system, we recommend that if you want to build this approach that instead of building "conventional routes" (i.e. MapRoute), that this instead use MVC's Application Model and Conventions to create attribute routes. They are both less error prone and can have better performance. Note: This doesn't mean using attribute routes anywhere in the code of the application - rather, it's using the underlying attribute routing system to compute the route logic. |
@Eilon - Would you have an example of what my touchpoints would be for that? Even just a quick example? Thanks! |
This is a good hello world example of dynamically configuring routing. https://github.com/aspnet/Entropy/tree/dev/samples/Mvc.CustomRoutingConvention Let us know if there are specific things you need help with |
Again, not sure I follow the advice here. I don't think what I'm suggesting is a convention. I specifically avoid attribute routing. I understand it's a feature you guys are trying to push, but it's not ideal. |
@atrauzzi this isn't about actually using attribute routing. For your scenario it just happens to be that some types have the term "attribute routing" in them, but none of your controllers or anything would use attribute routing. |
Got ya. The example linked seemed to be about creating a convention. Which I don't think I'd be doing? |
@atrauzzi - Were you using this with MVC Routing ie. app.UseMvc() or were you using purely custom routing? |
@mmacneil - On top of the MVC routing engine. I've come up with some conventions to get cleaner routing in my application, you can see the extensions here: https://github.com/atrauzzi/praxis/tree/master/Praxis/Routing This more or less is what I was looking for - although I don't doubt the ASP.net team could improve on it. While I haven't really documented this library, it is being used if you're interested. It's just a jumble of ideas & conventions I wanted for ASP.net Core projects. Unfortunately, only for 1.x. Haven't gotten into 2.x much. |
Thanks @atrauzzi ! I'll check it out. I hit the same sort of constraint with the MapVerb, MapGet etc. apis and used your AddVerb extension as part an attribute-less routing approach. Thanks, |
Yeah, I definitely wasn't looking to reinvent the wheel. Just that the current MVC APIs for routing really pale in comparison to other frameworks out there. Glad I could help! :) |
They're close to being useful, but I feel like they are still limited in application. What is needed is a way to define a name, the template, the controller and the action without having to resort to the anonymous types every time.
Right now in one of my projects, I define a set of extension methods as follows:
My
AddVerb
is similar in intention toMapVerb
, except that it usesMapRoute
so that I can gain the benefit of route names:What's missing here compared to
MapVerb
is:controller
andaction
rather than aRequestDelegate
I'm not sure if this is because the
Map*
series is an abstraction at the middleware level andMapRoute
is an abstraction at the MVC level. But I've campaigned in the past (1, 2) for a better API for route declaration. I think this is still an area where ASP.net Core can improve greatly.High level suggestions would be:
The text was updated successfully, but these errors were encountered: