0

I m using mvc4. I have urls like http://<mydomain>/<contoller0>/<action1> , http://<mydomain>/<contoller0>/<action2>,...
I want to show to the user only as http://<mydomain>/<contoller0>/{somepage} for all the actions in that particular controller.
How to impliment this in RouteConfig? I dont want to mess any requests to other controllers. Just want to do it for a specific controller and its actions.
How can I do it.

Currently my RoutConfig.cs look lik this.(It s the default)

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

Edited by jrosh

2
Contributors
1
Reply
17
Views
4 Years
Discussion Span
Last Post by LastMitch
0

How to impliment this in RouteConfig? I dont want to mess any requests to other controllers. Just want to do it for a specific controller and its actions. How can I do it.

The question you ask is borderline between SEO URL friendly and URL rewrite so it's bit tircky how to approached this.

The reason is that you wants how to the user only and it seems you don't know where to start to make changes you can used this:

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

and try this:

http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.