2

I am trying to create a custom controller for a taxonomy keywords navigation module in DXA1.4 .Net; however, I always hit the same error:

The controller for path '/taxonomy/test' was not found or does not implement IController.

I have declared my Module:Controller in the Component Template Component Template

And this relates to the Controller in my project, which I deploy to my Site for testing:

Solution Screenshot

I deploy the Controllers to the Site in a DLL by using the xcopy function, but I am sure this is not the issue here.

My ViewModel is registered as follows:

ViewModel Registration

And my Controller is shown here:

enter image description here

Please let me know if you need more info...

Thank you for taking the time to look.

Add on information:

When I run the site in Visual Studio we get the following break at the Main view (detailed in my Component Template MetaData) at the Html.DxaEntities() method.

enter image description here

6
  • Do you have a route to the NavigationTaxonomyController defined in Global.asax.cs ? Commented Jul 28, 2016 at 20:59
  • Hi Rick, thank you for responding. No I didn't and I am not sure how to do this as I do not see a Global.asax.cs in the DXA project. Do I need to create the class and do you have an example of the route please? Commented Jul 29, 2016 at 8:28
  • Is the update of the Global.asax.cs file something new? We have in the training where we create a custom controller in our new module and there is no need for us to update the Global.asax.cs for this to work.
    – TridionNut
    Commented Jul 29, 2016 at 15:26
  • Indeed, Entity Controllers don't have to be registered explicitly in Global.asax.cs; that's taken care of by BaseAreaRegistration, I was just wondering where the URL path came from (since it doesn't seem to match the name of a controller nor action). Commented Jul 29, 2016 at 15:41

1 Answer 1

3

I guess that (part of) the problem is that your controller classes are not explicitly declared as public (and the default visibility for classes is internal in C#).

I also don't understand why the URL path in the error message is /taxonomy/test; the (virtual) URL path for Entity Controllers registered in BaseAreaRegistration is in format /{controller}/{action}, so it seems that is trying to invoke the test action/method on the taxonomy controller (TaxonomyController) for some reason.

3
  • I just noticed that the classes were not public. I have made them public now and rebuilt the solution and now i am getting the following Error: 2016-07-29 17:15:27,041 [8] ERROR - Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at Taxonomy.Providers.KeywordProvider.RetrieveKeywords(String categoryId) at Taxonomy.Controllers.NavigationTaxonomyController.EnrichModel(ViewModel model)
    – TridionNut
    Commented Jul 29, 2016 at 17:18
  • So apparently your NavigationTaxonomyController now gets invoked successfully, but there is a problem in its implementation. Sounds like the original problem has been solved. Commented Jul 29, 2016 at 17:21
  • The shifting of the classes to public has allowed the controllers to get invoked, The error message I fixed, it turns out the schema fields it was looking for the casing was wrong. It seems to be working now. Thanks!
    – TridionNut
    Commented Jul 29, 2016 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.