简体   繁体   English

如何在不使用ASP.NET的情况下用C#创建REST服务

[英]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.

相关问题 从C#或ASP.Net开始REST Web服务的位置 - Where to start REST web service in C# or ASP.Net ASP.NET 如何将 C# 变量与 Z4C4AD5FCA2E7A3F74DBB1CED0038 的 rest 变量分开 - ASP.NET How to separate a C# variable from the rest of HTML without a space 计划在ASP.NET Windows Service(C#)中使用Node.js - Planning to use nodejs in asp.net windows service(C#) C#ASP.Net:如何在不使用WSDL或代理类的情况下在.NET 4.0 C#中调用Web服务 - C# ASP.Net : How to call a web service in .NET 4.0 C# without using the WSDL or proxy classes 如何在 c# asp.net 中使用 crud 操作创建 windows 服务 - how to create windows service using crud operations in c# asp.net 如何在不使用ASPNETDB.MDF的情况下使用角色管理 - asp.net/c# - how can i use rolemanagement without the use of ASPNETDB.MDF - asp.net/c# 如何在 c# asp.net 内核中使用 web 服务 - How to consume a web service in c# asp.net core 如何在不使用AJAX工具箱的标签容器的情况下使用ASP.NET和C#创建网页? - How to create a webpage using ASP.NET and C# without using AJAX Toolkit's Tab Container? 如何使用C#在asp.net中动态创建datetimepicker(没有类)? - How to create datetimepicker dynamically(without class) in asp.net with C#? 我们如何在没有 ASP.NET 的情况下使用 C# 和 JS 框架来开发单页应用程序? - How can we use C# without ASP.NET with a JS framework for developing Single Page Applications?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM