C# Map*与Map中间件*
ASP.NET核心MVC具有路由映射方法:C# Map*与Map中间件*,c#,.net,asp.net-core,C#,.net,Asp.net Core,ASP.NET核心MVC具有路由映射方法: 马普杰 映射删除 地图柱 地图输出 映射动词 使用中间件: 米德尔瓦雷吉特地图 MapMiddlewareDelete 米德尔瓦雷波斯特地图 米德尔瓦雷普特地图 米德尔瓦鲁特地图 米德尔瓦雷沃地图 有什么区别吗? 他们在视觉上解决了同样的问题 什么时候使用一个而不是另一个?您可以看到方法签名的区别: public static IRouteBuilder MapVerb(this IRouteBuilder builder, strin
- 马普杰
- 映射删除
- 地图柱
- 地图输出
- 映射动词
- 米德尔瓦雷吉特地图
- MapMiddlewareDelete
- 米德尔瓦雷波斯特地图
- 米德尔瓦雷普特地图
- 米德尔瓦鲁特地图
- 米德尔瓦雷沃地图
什么时候使用一个而不是另一个?您可以看到方法签名的区别:
public static IRouteBuilder MapVerb(this IRouteBuilder builder,
string verb, string template, RequestDelegate handler);
public static IRouteBuilder MapMiddlewareVerb(this IRouteBuilder builder,
string verb, string template, Action<IApplicationBuilder> action);
另一方面,用于注册应用程序生成器管道。这基本上允许您分叉中间件管道并在特定路由上执行中间件。这类似于直接分叉中间件管道。但是mapmidlewareverb
使用端点路由来实现这一点:
route.MapMiddlewareGet("/test", testApp =>
{
testApp.UseStaticFiles();
testApp.UseMiddleware<MyCustomMiddleware>();
});
route.mapmidlewareget(“/test”,testApp=>
{
testApp.UseStaticFiles();
testApp.useMediddleware();
});
至于其他具有特定谓词的方法,它们只是
MapVerb(,…)
和MapMiddlewareVerb(,…)
的快捷方式,您可以从方法签名中看到区别:
public static IRouteBuilder MapVerb(this IRouteBuilder builder,
string verb, string template, RequestDelegate handler);
public static IRouteBuilder MapMiddlewareVerb(this IRouteBuilder builder,
string verb, string template, Action<IApplicationBuilder> action);
另一方面,用于注册应用程序生成器管道。这基本上允许您分叉中间件管道并在特定路由上执行中间件。这类似于直接分叉中间件管道。但是mapmidlewareverb
使用端点路由来实现这一点:
route.MapMiddlewareGet("/test", testApp =>
{
testApp.UseStaticFiles();
testApp.UseMiddleware<MyCustomMiddleware>();
});
route.mapmidlewareget(“/test”,testApp=>
{
testApp.UseStaticFiles();
testApp.useMediddleware();
});
至于其他具有特定动词的方法,它们只是MapVerb(,…)
和MapMiddlewareVerb(,…)
的快捷方式