dotnet / dotnet/aspnetcore

IRouter.GetVirtualPath alternative in EndpointRouting

Open
#23,041 9 comments 3 reactions 0 assignees View on GitHub
affected-very-few area-mvc enhancement feature-routing Priority:1 severity-major
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

Based on this topic:
https://github.com/dotnet/aspnetcore/issues/18883

The "IRouter.RouteAsync" alternative is "DynamicRouteValueTransformer.TransformAsync".

**What is the "VirtualPathData GetVirtualPath(VirtualPathContext context)" alternative for complex url generation?**

For example:
```
public override VirtualPathData GetVirtualPath(VirtualPathContext context)
{
var routeContext = context["context"] as new ProductListRouteContext();
var pathSegements = new List();
if (context?.Category?.PageName != null)
{
pathSegments.Add(context.Category.PageName);
}
// Add other pathSegements based on the context/filters...
return new new VirtualPathData(this, string.Join("/", pathSegments));
}
```
In my view:

`Url.RouteUrl("ProductList", new { context = Model.ProductListRouteContext });`

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked issue about EndpointRouting, then compare IRouter.RouteAsync and DynamicRouteValueTransformer.TransformAsync with the GetVirtualPath and Url.RouteUrl entry points shown here. Determine whether EndpointRouting exposes a supported alternative for complex URL generation; done means the alternative and its usage are clearly documented or the gap is explicitly defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.