You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on an .NET Core MVC application which requires alternative controller/action names to be allowed. To accomplish this, I am using my own Router on a MapRoute:
My custom router observes the requested controller and action, and based on it places a new value into the RouteData in the request:
public async Task RouteAsync(RouteContext context)
{
[...]
if (requestedAction == "fakeAction")
context.RouteData.Values["action"] = "realAction";
However, to determine the value of the requestedAction, I am basically taking the requested path, splitting it and getting the value of it that way. This seems suboptimal.
What I would like to do would look something like this:
var rr = new RouteBuilder(app);
var myRoute = rr.MapRoute(...).Build();
var myRouteData = myRoute.GetRouteData(context);
myRouteData["action"] == "fakeAction";
Another solution to this problem which I would very much enjoy is if I could do the following:
But NOT have my something route actually route anything and only serve as a way to define the RouteData for my CustomRouter.
Is either of these possible? I do not like the idea us uncleanly implementing existing functionality as it is a both a code smell and a potential maintenance difficulty in the future.
The text was updated successfully, but these errors were encountered:
I am working on an .NET Core MVC application which requires alternative controller/action names to be allowed. To accomplish this, I am using my own Router on a MapRoute:
My custom router observes the requested controller and action, and based on it places a new value into the RouteData in the request:
However, to determine the value of the requestedAction, I am basically taking the requested path, splitting it and getting the value of it that way. This seems suboptimal.
What I would like to do would look something like this:
Another solution to this problem which I would very much enjoy is if I could do the following:
But NOT have my something route actually route anything and only serve as a way to define the RouteData for my CustomRouter.
Is either of these possible? I do not like the idea us uncleanly implementing existing functionality as it is a both a code smell and a potential maintenance difficulty in the future.
The text was updated successfully, but these errors were encountered: