[英]How to create a REST-Service in C# without the use of ASP.NET
I try to create a Text-To-Speech service in windows. 我尝试在Windows中创建“文字转语音”服务。 The API should be exposed using a REST API.
该API应使用REST API公开。 Unfortunately I only find examples using ASP.NET.
不幸的是,我仅找到使用ASP.NET的示例。 Is it possible to create such a service without the use of ASP.
是否可以在不使用ASP的情况下创建此类服务。 Any hints or examples would be much appreciated.
任何提示或示例将不胜感激。
I searched both google and stackoverflow; 我同时搜索了google和stackoverflow; but could not find information or examples to achieve this.
但找不到实现此目的的信息或示例。
You can view the Networking\\Writing an HTTP Server
chapter in brothers' Albahari "C# 7.0 in a Nutshell" book. 您可以在兄弟俩的Albahari的“坚果壳中的C#7.0”一书中查看“
Networking\\Writing an HTTP Server
一章。
It would be something like 就像
HttpListener listener = new HttpListener();
listener.Prefixes.Add ("http://localhost:51111/MyApp/"); // Listen on 51111
listener.Start();
But it's definetly not the easiest way to do so. 但这绝对不是最简单的方法。 You'll have to write too much low-level code.
您将不得不编写过多的低级代码。
Just use web API with ASP.NET Core MVC. 只需将Web API与ASP.NET Core MVC一起使用。 You can find more information here: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.2&tabs=visual-studio
您可以在此处找到更多信息: https : //docs.microsoft.com/zh-cn/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.2&tabs=visual-studio
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.