views:

26

answers:

3

I'm writing a simple news site. I want that the URL will be something like this:

http://domain.com/killing-puts-focus-on-crimes-against-latinos

...instead of the basic Controller-View-ID structure. I do not want something like:

http://domain.com/news/killing-puts-focus-on-crimes-against-latinos

How can I do this?

Thanks.

+1  A: 

You will want to define what is know as a Catch All route.

Try something similar to:

        routes.MapRoute(
            "News",                                              
            "{*title}",                           
            new { controller = "News", action = "Index" }  
        );
Jason Whitehorn
+1  A: 

You need a route that looks something like this:

routes.MapRoute (
   "Article",                                             
   "{title}",                          
   new { controller = "Article", action = "Index", title = "" }  
);
Robert Harvey
A: 

You could use the default value for the controller name (like for HomeController). http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx

Sly