简体   繁体   English

使用控制台应用程序创建ASP.NET WEB API

[英]Create ASP.NET WEB API using Console application

I have seen many articles in Internet to create RESTFUL webapi by selecting webapi project as project type. 我在Internet上看到过很多文章,通过选择webapi项目作为项目类型来创建RESTFUL webapi。 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. 可执行文件如何为我们提供要从客户端应用程序使用的URL。

Yes, there is a possibility. 是的,有可能。 but we need to flow some steps to achieve this. 但是我们需要采取一些步骤来实现这一目标。

  1. we should use OwinSelfHost package for self hosting. 我们应该使用OwinSelfHost软件包进行自我托管。
  2. we should create as class file that inherits from ApiController. 我们应该创建一个继承自ApiController的类文件。
  3. install cors package for webapi application that is used for client to consume the application. 为客户端使用Webapi应用程序安装cors软件包以使用该应用程序。

Hosting: domain name or IP should be given where the service is hosted. 托管:应在托管服务的位置提供域名或IP。

Reference Example 参考例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# Console application wont post large dataset to asp.net .net core 3.0 web api - C# Console application wont post large dataset to asp.net .net core 3.0 web api asp.net 内核中的控制台应用程序和 Web 应用程序之间的区别 - Difference between a console application and Web application in asp.net core 如何通过桌面/控制台应用程序使用带有不记名令牌的 ASP.NET Web API 2.0 - How to consume ASP.NET Web API 2.0 with bearer token via a desktop/console application 从控制台应用程序身份验证标头调用ASP.NET Web Api - ASP.NET Web Api call from console application authentication header ASP.NET:使用控制台应用程序调用Web窗体应用程序的方法 - Asp.net: using Console application call Web-form application's method 使用 .NET Core Web API 作为 ASP.NET Web Forms 应用程序的子路由 - Using .NET Core Web API as subroute of ASP.NET Web Forms Application 从我的asp.net mvc Web应用程序调用asp.net控制台应用程序 - Calling an asp.net console application from my asp.net mvc web application 如何在 Web 中调用控制台应用程序功能 forms 在 asp.net 中 - How to call Console Application functions in Web forms in asp.net 在ASP.NET Web应用程序中使用功能 - Using function in ASP.NET web application 使用Watin的ASP.NET Web应用程序 - ASP.NET Web Application using Watin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM