© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
caciocode

❔ ASP.NET Core ignoring custom DynamicRouteValueTransformer

I have created a custom DynamicRouteValueTransformer to help me switch between 2 controllers and actions but the route values are not being used by ASP.NET Core. Here is how the tranform looks;

    public class UserModeTransformer : DynamicRouteValueTransformer
    {
        /*public readonly ApplicationDbContext _context;

        public UserModeTransformer(ApplicationDbContext context)
        {
            _context = context;
        }*/

        public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext httpContext, RouteValueDictionary values)
        {
            values = new RouteValueDictionary();
            values["area"] = "Candidate";
            values["controller"] = "SocialController";
            values["action"] = "Index"; 
            return values;
        }
    }
    public class UserModeTransformer : DynamicRouteValueTransformer
    {
        /*public readonly ApplicationDbContext _context;

        public UserModeTransformer(ApplicationDbContext context)
        {
            _context = context;
        }*/

        public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext httpContext, RouteValueDictionary values)
        {
            values = new RouteValueDictionary();
            values["area"] = "Candidate";
            values["controller"] = "SocialController";
            values["action"] = "Index"; 
            return values;
        }
    }


For now I am just providing the controller and action but it is returning 404 error in the browser although the controllers and actions exist.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ASP.NET to .net Core
C#CC# / help
3y ago
❔ ASP.NET Core Custom Font Not Applied
C#CC# / help
3y ago
ASP.NET CORE MVC VS ASP.NET CORE WEB API
C#CC# / help
17mo ago