0

I have a Product.Core MVC project. This project has some common API controllers.

I have another MVC project "Product" that references Product.Core.

The API controllers work as expected. I can call APIs defined in both solutions.

I now want to extended one of the API controllers in Product.Core. Say XXXApiController.

I have the same controller defined in the Product project.

    namespace Product
    {
        public class XXXApiController : Product.Core.XXXApiController
        {
            public new Task<XXXResponse> MyApiAsync()
            {
                var response = await base.MyApiAsync();
                // do extra code here
                return response;
            }
        }
    }

However, after this change it seems the XXXApiController is no longer available. I get a 'No HTTP resource was found' error.

How can I extend an API controller that lives in another MVC project?

rukiman
  • 597
  • 10
  • 32
  • Extending c# code with separate assembly https://stackoverflow.com/questions/713060/extending-c-sharp-code-with-separate-assembly – Roman Ryzhiy Sep 25 '20 at 08:03
  • My question is more to do with routing issues, I have already extended the APIController and the project builds and deploys. However routing is broken for that APIController that was extended – rukiman Sep 25 '20 at 08:06
  • If you're using convention based routing controller names should differ by more than just their namespace. I'm not saying that's the issue here but it's worth noting – Aluan Haddad Sep 25 '20 at 08:15
  • I am using the convention based routing. Are you saying I call the new controller a different name but put a routing prefix so that this inheritance is transparent to clients connecting to this web service? I haven't tried this. – rukiman Sep 25 '20 at 08:40

0 Answers0