<p>I'm new to MVC (and ASP.Net routing).  I'm trying to map <code>*.aspx</code> to a controller called <code>PageController</code>.  </p>

<pre><code>routes.MapRoute(
   "Page",
   "{name}.aspx",
   new { controller = "Page", action = "Index", id = "" }
);
</code></pre>

<p>Wouldn't the code above map *.aspx to <code>PageController</code>?  When I run this and type in any .aspx page I get the following error:</p>

<blockquote>
  <p>The controller for path '/Page.aspx' could not be found or it does not implement the IController interface.
  Parameter name: controllerType</p>
</blockquote>

<p>Is there something I'm not doing here?</p>

[{'answer_id': 11937, 'author': 'Dale Ragan', 'author_id': 1117, 'author_profile': 'https://Stackoverflow.com/users/1117', 'pm_score': 0, 'selected': False, 'text': '<p>Not sure how your controller looks, the error seems to be pointing to the fact that it can\'t find the controller.  Did you inherit off of Controller after creating the PageController class?  Is the PageController located in the Controllers directory?</p>\n\n<p>Here is my route in the Global.asax.cs</p>\n\n<pre><code>routes.MapRoute(\n    "Page", \n    "{Page}.aspx", \n    new { controller = "Page", action = "Index", id = "" }\n);\n</code></pre>\n\n<p>Here is my controller, which is located in the Controllers folder:</p>\n\n<pre><code>using System.Web.Mvc;\n\nnamespace MvcApplication1.Controllers\n{\n    public class PageController : Controller\n    {\n        public void Index()\n        {\n            Response.Write("Page.aspx content.");\n        }\n    }\n}\n</code></pre>\n'}, {'answer_id': 11946, 'author': 'Ryan Eastabrook', 'author_id': 105, 'author_profile': 'https://Stackoverflow.com/users/105', 'pm_score': 3, 'selected': False, 'text': '<p>I just answered my own question.  I had the routes backwards (Default was above page).  Below is the correct order.  So this brings up the next question... how does the "Default" route match (I assume they use regular expressions here) the "Page" route?</p>\n\n<pre><code>routes.MapRoute(\n            "Page",\n            "{Name}.aspx",\n            new { controller = "Page", action = "Display", id = "" }\n        );\n\n        routes.MapRoute(\n            "Default",                                              // Route name\n            "{controller}/{action}/{id}",                           // URL with parameters\n            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults\n        );\n</code></pre>\n'}, {'answer_id': 11957, 'author': 'Dale Ragan', 'author_id': 1117, 'author_profile': 'https://Stackoverflow.com/users/1117', 'pm_score': 4, 'selected': True, 'text': '<blockquote>\n  <p>I just answered my own question. I had\n  the routes backwards (Default was\n  above page).</p>\n</blockquote>\n\n<p>Yeah, you have to put all custom routes above the Default route.</p>\n\n<blockquote>\n  <p>So this brings up the next question...\n  how does the "Default" route match (I\n  assume they use regular expressions\n  here) the "Page" route?</p>\n</blockquote>\n\n<p>The Default route matches based on what we call Convention over Configuration.  Scott Guthrie explains it well in his first blog post on ASP.NET MVC.  I recommend that you read through it and also his other posts.  Keep in mind that these were posted based on the first CTP and the framework has changed.  You can also find web cast on ASP.NET MVC on the asp.net site by Scott Hanselman.</p>\n\n<ul>\n<li><a href="http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx</a></li>\n<li><a href="http://www.asp.net/MVC/" rel="noreferrer">http://www.asp.net/MVC/</a></li>\n</ul>\n'}, {'answer_id': 11962, 'author': 'Chris Farmer', 'author_id': 404, 'author_profile': 'https://Stackoverflow.com/users/404', 'pm_score': 1, 'selected': False, 'text': '<p>On one of Rob Conery\'s MVC Storefront <a href="http://www.asp.net/learn/3.5-SP1/video-356.aspx" rel="nofollow noreferrer">screencasts</a>, he encounters this exact issue.  It\'s at around the 23 minute mark if you\'re interested.</p>\n'}, {'answer_id': 4840639, 'author': 'Dayi Chen', 'author_id': 595443, 'author_profile': 'https://Stackoverflow.com/users/595443', 'pm_score': 0, 'selected': False, 'text': '<pre><code>public class AspxRouteConstraint : IRouteConstraint\n{\n    #region IRouteConstraint Members\n\n    public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)\n    {\n        return values["aspx"].ToString().EndsWith(".aspx");\n    }\n\n    #endregion\n}\n</code></pre>\n\n<p>register the route for all aspx</p>\n\n<pre><code>  routes.MapRoute("all", \n                "{*aspx}",//catch all url \n                new { Controller = "Page", Action = "index" }, \n                new AspxRouteConstraint() //return true when the url is end with ".aspx"\n               );\n</code></pre>\n\n<p>And you can test the routes by <a href="http://mvcroutevisualizer.codeplex.com" rel="nofollow">MvcRouteVisualizer</a> </p>\n'}]
['https://Stackoverflow.com/questions/11926', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/105/']