Custom names for types/namespaces

Imported from the CodePlex archive for reference purposes. Support for MvcCodeRouting has ended.

Commented on

Hello,

first of all thanks for the great job you have done with this library!

I would need to use custom names for some of the types and namespaces of my web application and I am wondering if McvCodeRouting supports this scenario. Basically, I would need to map a controller with a name like this:

TestApp.Controllers.MyCoolNamespace.MyController

To an url like this:

/my-cool-namespace/my-controller


I hoped that the RouteFormatter settings would allow me to do that but it seems that its support is limited to a simple casing-change scenario only.
Unfortunately, the following code throws an exception (Only case formatting is currently supported for Namespace route segments).

 

 

            routes.MapCodeRoutes(
               rootNamespace: typeof(Controllers.HomeController).Namespace,
               settings: new CodeRoutingSettings
               {
                   RouteFormatter = (segment, segmentType) =>
                    {
                        switch (segmentType)
                        {
                            case RouteSegmentType.Namespace:
                                {
                                    if (segment == "MyCoolNamespace")
                                    {
                                        return "my-cool-namespace";
                                    }

                                    break;
                                }
                        }

                        return segment;
                    }
               }


Am I missing something?

Thank you so much for your help.
Cheers! 

 

Commented on link

What you are trying to do is currently not supported, but it's something I intend to work on in the future. Stay tuned.

Commented on link

This is now supported (in the latest revision) for namespace segments. Next I'll be working on the support for controller segments.

Commented on link

Ditto for controller segments, coming in the next release.

Commented on link

Thanks a lot!

In the meanwhile, however, I've started a new MVC routing extension project on my own, built from scratch; so, unfortunately, I don't have the time to check the bounty of your new additions although I am sure they rock like everything else on this project.

Thanks again.
Cheers.