The controller for path '/Admin/Auctions/Create' was not found or does not implement IController.

Topics: Customizing Orchard, Troubleshooting, Writing modules
Aug 15, 2012 at 3:20 AM

Hi All,

been pulling my hair out trying to work out why orchard isn't playing ball with my new module.. I can't get any of the routing to work even though I think I've hooked it up right.. maybe I'm missing something..

 

I have a class in my namespace called routes doing the following:

		public void GetRoutes(ICollection<RouteDescriptor> routes)
		{
			foreach (var routeDescriptor in GetRoutes())
			{
				routes.Add(routeDescriptor);
			}
		}

		public IEnumerable<RouteDescriptor> GetRoutes()
		{
			return new[] {
                             new RouteDescriptor {
													 Priority = 16,
                                                     Route = new Route(
                                                         "Admin/Auctions/Create",
                                                         new RouteValueDictionary {
                                                                                      {"area", "Test.Auctions"},
                                                                                      {"controller", "AuctionAdmin"},
                                                                                      {"action", "Create"}
                                                                                  },
                                                         new RouteValueDictionary(),
                                                         new RouteValueDictionary {
                                                                                      {"area", "Test.Auctions"}
                                                                                  },
                                                         new MvcRouteHandler())
                                                 }};
												 }

I have an AuctionAdminController file which has the following method:

 public ActionResult Create() {
            if (!Services.Authorizer.Authorize(Permissions.ManageAuctions, T("Not allowed to create auctions")))
                return new HttpUnauthorizedResult();
			
            var auction = Services.ContentManager.New<AuctionPart>("Auction");
            if (auction == null)
                return HttpNotFound();

            dynamic model = Services.ContentManager.BuildEditor(auction);

            return View((object)model);
        }

and I just cannot get routing to work.. the menu item in the navigation is trying to request /Admin/Auctions/Create and blowing up..

 

If i attach and try and run there's nowhere in the run that I can see routes.cs being hit..

 

any help would be most appreciated.

Cheers,

Tom

Aug 15, 2012 at 4:05 AM
Edited Aug 15, 2012 at 4:06 AM

Is your Routes class implementing IRouteProvider?  Also, I usually make sure to keep the naming really consistent for modules.  So, in your case I would make sure that Test.Auctions is the name of the module in the manifest, the name of the folder the module is contained in, and that it's the name of the actual project and namespacing within the module.  I've run into your issue when these are not in sync before.  

And of course, make sure your module is enabled. :)

Aug 15, 2012 at 4:07 AM

Oh, and your Routes class must be public so Orchard can find it.

Aug 17, 2012 at 12:18 AM
Thanks so very much! that got me there it was a naming issue.. very stoaked to have it all working as expected!

On Fri, Aug 17, 2012 at 8:53 AM, BrandonJoyce <notifications@codeplex.com> wrote:

From: BrandonJoyce

Is your Routes class implementing IRouteProvider? Also, I usually make sure to keep the naming really consistent for modules. So, in your case I would make sure that Test.Auctions is the name of the module in the manifest, the name of the folder the module is contained in, and that it's the name of the actual project and namespacing within the module. I've run into your issue when these are not in sync before.

And of course, make sure your module is enabled. :)

Read the full discussion online.

To add a post to this discussion, reply to this email (orchard@discussions.codeplex.com)

To start a new discussion for this project, email orchard@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com