问题
I have seen many articles in Internet to create RESTFUL webapi by selecting webapi project as project type. Is there any possibility that we can create the same using console application. if possible, how can it be hosted? how Executable file gives us the URL to consume from client application.
回答1:
Yes, there is a possibility. but we need to flow some steps to achieve this.
- we should use OwinSelfHost package for self hosting.
- we should create as class file that inherits from ApiController.
- install cors package for webapi application that is used for client to consume the application.
Hosting: domain name or IP should be given where the service is hosted.
Reference Example
来源:https://stackoverflow.com/questions/45790187/create-asp-net-web-api-using-console-application