简体   繁体   English

ASP.NET 核心 Web API - 创建自定义请求和响应

[英]ASP.NET Core Web API - Create Custom Requests and Responses

I'm completely new to .NET and C# programming.我对 .NET 和 C# 编程完全陌生。 I'm working on a project that requires me to develop a .NET base web application.我正在从事一个项目,需要我开发一个 .NET 基础 web 应用程序。

I have been able to do most parts of the project but I'm having issues with the ASP.NET Core Web API.我已经能够完成项目的大部分工作,但我遇到了 ASP.NET Core Web API 问题。

I want to make HTTP Get request from the front end but I do not know how to remove the WeatherForecast sample and write my own requests and response.我想从前端发出 HTTP Get 请求,但我不知道如何删除WeatherForecast示例并编写我自己的请求和响应。

Any help regarding how to create the basic template for the HTTP requests would be highly appreciated.非常感谢有关如何为 HTTP 请求创建基本模板的任何帮助。

Thank you!谢谢!

I want to make HTTP Get request from the front end Web api doesn't contain front end.If you want to send requests in web api,you can try to use HttpClient,here is a sample with get request: I want to make HTTP Get request from the front end Web api 不包含前端。如果你想在 web api 中发送请求,你可以尝试使用 HttpClient,这里是一个获取请求的示例:

HttpClient client = new HttpClient();
 HttpResponseMessage response = await client.GetAsync("{url}");

For more details,you can refer to the doc .有关更多详细信息,您可以参考文档

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM