[英]is RequestDelegate an endpoint?
I'm new to asp.net core 3.0 and struggling in understanding the concept of endpoint.我是 asp.net 核心 3.0 的新手,并且在理解端点的概念方面遇到了困难。 https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-5.0 says: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-5.0说:
An endpoint is something that can be: a.Selected, by matching the URL and HTTP method.端点可以是: a. 通过匹配 URL 和 HTTP 方法来选择。 b.Executed, by running the delegate. b.通过运行委托来执行。
Below is the template code:下面是模板代码:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
}
can I say the RequestDelegate
我可以说RequestDelegate
async context => {
await context.Response.WriteAsync("Hello World!");
}
is an endpoint?是端点?
can I say the RequestDelegate我可以说 RequestDelegate
async context => { await context.Response.WriteAsync("Hello World;"); }
is an endpoint?是端点?
No, it is a request delegate, instead of a endpoint.不,它是请求委托,而不是端点。 When an HTTP GET request is sent to the root URL /
(endpoint): The request delegate shown executes.当 HTTP GET 请求发送到根 URL /
(端点)时:显示的请求委托执行。 "Hello World." “你好世界。” is written to the HTTP response.写入 HTTP 响应。
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
But, using the above code, the MapGet method defines an endpoint.但是,使用上面的代码,MapGet 方法定义了一个端点。 As the documents said:正如文件所说:
Besides, you could also check the MapGet method:此外,您还可以检查 MapGet 方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.