0

Default ASP.NET MVC project has one MapRoute like

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

And urls like these are equivalent: www.mysite.com, www.mysite.com/home, www.mysite.com/home/index

But if I trying to use a MapRoute like

            routes.MapRoute(
            "Sitemap",
            "{controller}/{action}",
            new { controller = "Sitemap", action = "ShortMap" }
        );

and test url www.mysite.com/sitemap I recieve error 404 but I'm expecting that it's work like www.mysite.com/sitemap/shortmap

How to write this MapRoute correctly?

shadeglare
  • 7,006
  • 7
  • 47
  • 59

3 Answers3

1

You should probably spell the word controller correctly.

You have it spelled contoller

Jason Watts
  • 3,800
  • 29
  • 33
  • Just mistake in question not in code. I solved the problem by this code: routes.MapRoute( "MainPage", "", new { controller="Home", action="Index" } ); routes.MapRoute( "Sitemap", "Sitemap/{action}", new { controller = "Sitemap", action = "ShortMap" } ); Now www.mysite.com/sitemap and www.mysite.com/sitemap/shortmap are equivalent. It was not work because of the default MapRoute influnce. – shadeglare May 09 '10 at 02:31
0

Best thing I have found to aid in map route issues is Phil Haack's route tool http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx. It's a great way to see which and how your routes are being used.

What happens when you try /sitemap/action

Brettski
  • 19,351
  • 15
  • 74
  • 97
0

Make sure that the view "ShortMap" really exists. I know, it's simple - but happened to me a few times.

Dänu
  • 5,791
  • 9
  • 43
  • 56