使用控制台应用程序创建ASP.NET WEB API [英] Create ASP.NET WEB API using Console application

查看:229
本文介绍了使用控制台应用程序创建ASP.NET WEB API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Internet上看到很多文章,通过选择webapi项目作为项目类型来创建RESTFUL webapi.我们是否有可能使用控制台应用程序来创建相同的应用程序.如果可能,如何托管?可执行文件如何为我们提供要从客户端应用程序使用的URL.

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.

推荐答案

是的,有可能.但是我们需要采取一些步骤来实现这一目标.

Yes, there is a possibility. but we need to flow some steps to achieve this.

  1. 我们应该使用OwinSelfHost软件包进行自我托管.
  2. 我们应该创建一个继承自ApiController的类文件.
  3. 为客户端使用该应用程序的webapi应用程序安装cors软件包.

托管: 托管服务的位置应提供域名或IP.

Hosting: domain name or IP should be given where the service is hosted.

参考示例

这篇关于使用控制台应用程序创建ASP.NET WEB API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆