Venki
Venki

Reputation: 543

Create an ASP.NET Web API using a Console application

I have seen many articles in Internet to create a RESTful Web API by selecting the 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 does an executable file gives us the URL to consume from the client application?

Upvotes: 5

Views: 12101

Answers (1)

Rock star
Rock star

Reputation: 201

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

Upvotes: 7

Related Questions