-
Notifications
You must be signed in to change notification settings - Fork 10.3k
.net Core 2.2 - Generate RouteData from Url path #4597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am having the same issue after scaffolding the Identity. The callbackUrl always returns null. Page: Register.cshtml.cs |
@mgolois - hi, sorry for the delayed response. It's not 100% clear to me what you're trying to do, so I'm guessing. If what you want is to parse a URL into route values, you can use the I'm closing this issue since I believe I answered the question. Feel free to open another issue is this is not what you need. @MarxITSolutions - if you're still having this problem could you please open a new issue and include a minimal repro of the problem so that we can investigate? Thanks! |
@rynowak , in order to use TemplateMatcher I need to get the teamples, so all route collections. Basically, after upgrading to 2.2 I would like to use the new routing system, the application has a method that contains a list of strings (urlPaths) and needs to generate RouteData of each urlPaths. |
I also would like to do this. How can we get a collection of routers in the new route system? |
Ok. So i dont know about @rynowak but I use conventional route patterns. I know everyone loves attribute routing but I don't see the appeal but I believe this approach could work with that as well. What I am doing now is after registering the routes in the UseMvc extension method like this
I then loop the routes collection here and add the route templates to an internal static collection in the startup.cs class. Then I can access all the templates anywhere in the code and match them using the matcher. This allows me to get a collection of route values and a match from a path string like "/Home/Index". I cannot help feeling there should be an easier way...
Then I can access the registered route templates with Startup.MvcRoutes and subsequently use the pattern matcher to parse the path string. Im a bit rushed at the moment but can I suggest maybe just reverting to populating RouteData.Routes ? |
Adds functionality to LinkGenerator to parse a URI path given a way to find an endpoint. This is the replacement for various machinications using the global route collection and `RouteData.Routers` in earlier versions. For now I'm just adding a way to do this using Endpoint Name since it's a pretty low level feature. Endpoint Name is also very direct, so it feels good for something like this. I added this to LinkGenerator because I think it feels like the right thing do, despite the naming conflict. I don't really want to create a new top-level service for this.
Adds functionality to LinkGenerator to parse a URI path given a way to find an endpoint. This is the replacement for various machinications using the global route collection and `RouteData.Routers` in earlier versions. For now I'm just adding a way to do this using Endpoint Name since it's a pretty low level feature. Endpoint Name is also very direct, so it feels good for something like this. I added this to LinkGenerator because I think it feels like the right thing do, despite the naming conflict. I don't really want to create a new top-level service for this.
Adds functionality to LinkGenerator to parse a URI path given a way to find an endpoint. This is the replacement for various machinications using the global route collection and `RouteData.Routers` in earlier versions. For now I'm just adding a way to do this using Endpoint Name since it's a pretty low level feature. Endpoint Name is also very direct, so it feels good for something like this. I added this to LinkGenerator because I think it feels like the right thing do, despite the naming conflict. I don't really want to create a new top-level service for this.
Adds functionality to LinkGenerator to parse a URI path given a way to find an endpoint. This is the replacement for various machinications using the global route collection and `RouteData.Routers` in earlier versions. For now I'm just adding a way to do this using Endpoint Name since it's a pretty low level feature. Endpoint Name is also very direct, so it feels good for something like this. I added this to LinkGenerator because I think it feels like the right thing do, despite the naming conflict. I don't really want to create a new top-level service for this.
I've added a new singleton service that can be used to parse a URL path given an endpoint/route name. See #9728 for details. Coming soon to official docs. |
That's brilliant thanks! I might be being a bit thick here but could you link to the implementation? |
Oops it's #9728 - fixed my link, thanks |
Hello,
I'm looking for documentation on the new endpoint routing system. I'm upgrading from .net core 2.1 to 2.2. I have a scenario where I need to generate the RouteData object from a url path.
I could not get it to work with IUrlHelper.
Thanks!
The text was updated successfully, but these errors were encountered: