I created some simple mvc app that lists categories from the database, like in northwind sample posted by phil. I added another controller and modified default routing rule so that it uses my new controller, and excluded HomeController from the project.
Now route is as follows
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "products", action = "categories", id = "" } // Parameter defaults
);
and my controller code is same as in Northwind sample
public ActionResult Index() {
// Add action logic herereturn Categories();
}
public ActionResult Categories() {
return View("Categories", repository.Categories.ToList());
}
Now, when I start debugging, I am redirected again to /Home and of course, I receive "The controller for path '/Home' could not be found or it does not implement the IController interface.
Parameter name: controllerType" error.
Sorry for the confusion in default.aspx! We plan to have better guidance in a future release of ASP.NET MVC and routing. There are a few steps you need to take when changing the default paths of the site and right now it isn't 100% clear to users what they
need to do to make it work. I'm glad you got it working.
panjkov
Member
529 Points
169 Posts
simple routing question - probably asked before...
Jun 16, 2008 10:58 PM|LINK
hello
I created some simple mvc app that lists categories from the database, like in northwind sample posted by phil. I added another controller and modified default routing rule so that it uses my new controller, and excluded HomeController from the project.
Now route is as follows
routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "products", action = "categories", id = "" } // Parameter defaults );and my controller code is same as in Northwind sample
Now, when I start debugging, I am redirected again to /Home and of course, I receive "The controller for path '/Home' could not be found or it does not implement the IController interface.
Parameter name: controllerType" error.
Is that bug in CTP3 or am I missing something?
THX
Dragan
routing asP.net mvc preview 3
[http://www.dragan-panjkov.com/]
panjkov
Member
529 Points
169 Posts
Re: simple routing question - probably asked before...
Jun 16, 2008 11:10 PM|LINK
solved.
default.aspx is redirecting to ~/Home on Page load. After changing controller name in here, I now have my redirect working.
[http://www.dragan-panjkov.com/]
Eilon
Contributor
5753 Points
976 Posts
Microsoft
Re: simple routing question - probably asked before...
Jun 17, 2008 05:49 AM|LINK
Hi Dragan,
Sorry for the confusion in default.aspx! We plan to have better guidance in a future release of ASP.NET MVC and routing. There are a few steps you need to take when changing the default paths of the site and right now it isn't 100% clear to users what they need to do to make it work. I'm glad you got it working.
Thanks,
Eilon