Search code examples
asp.net-core-2.0asp.net-core-webapiasp.net-mvc-controller

ASP.NET CORE 2.2 call to web api targeting .net framework does not get called


I have a solution with contains a class library targeting the .Net framework 4.7 and another project with ASP.NET Core 2.2 .

The class library targeting the .Net framework contains controllers as shown below with the route prefix and the route name

enter image description here

And then in my StartUp.cs i have configured the below enter image description here

On running this i make a call to the api in the .Net framework class library the call does not return the response from the web api instead returns the default index.html content.

enter image description here What am i missing in this ?


Solution

  • I see on the first screen classes like RoutePrefix, ApiController, HttpResponseMessage. They are from classic Asp.Net WebApi. It is impossible to use old ApiControllers in Asp.Net Core. It means you need to rewrite you controllers using Asp.net Core.

    Asp.net core projects may targeting to both .net core and classic .Net Framework. If you really need to target to the .Net Framework you can create a class library targeting the .Net framework 4.7, create there Asp.Net Core controllers and then use that library in Asp.Net Core project as an external dll.