Create ASP.NET WEB API using Console application

最后都变了- 提交于 2019-12-19 10:39:07

问题


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.

  1. we should use OwinSelfHost package for self hosting.
  2. we should create as class file that inherits from ApiController.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!