.NET Framework 4.0 Alternative to Microsoft.AspNet.WebApi.OwinSelfHost

585 Views Asked by At

I have an old windows application that runs on .NET Framework 4.0 that now needs to selfhost a web service in order to respond to Web API calls. For that, I tried to setup OwinSelfHost library, but when I try to install through Nuget, I get the following error:

Could not install package 'Microsoft.AspNet.WebApi.OwinSelfHost ', You are trying to install this package into a project that targets '.NETFramework,Version=4.0', but the package does not contain any assembly references or content files that are compatible with that framework."

I tried to install the legacy library, Microsoft.AspNet.WebApi.Selfhost, but I also get the same issue. Is there an alternative library that I can use?

Looking for a short term solution, I'm aware updating the framework would be a better long term solution, but the scope in development, deployment, testing, etc. is not be manageable at this cycle.

1

There are 1 best solutions below

0
On

Yes, you can use the HttpListener class. It is what OWIN ultimately uses as well. However, you will have to handle all aspects of the HTTP request and response. You will not get anything like the ApiController class, routing, or parameter binding. You should be able to find many examples.