Cannot see index view of my controller - routing related

Posted by olst on Stack Overflow See other posts from Stack Overflow or by olst
Published on 2010-03-12T16:32:58Z Indexed on 2010/03/12 16:37 UTC
Read the original article Hit count: 189

Filed under:
|

Hi. I have a controller named Content, which has an Index action, which is associated with a view.

I would like the simple route "content" to show me the index view of the content controller, so I use the following code (with the addition of the default site home route):

        routes.MapRoute(
            "ContentIndex",
            "content",
            new { controller = "Content", action = "Index"}
        );


        routes.MapRoute(
          "Default",
          "{controller}/{action}",
          new { controller = "Home", action = "Index" }
        );

when I type the url : "http://localhost/content/", I get an error 404 saying the resource cannot be found, but when I type "http://localhost/content/index", it shows the content index view. How can I get rid of the index in the url ?

Thanks !

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about routes