受保护的覆盖 IAsyncResult BeginExecute - 移植到 .net 核心
protected override IAsyncResult BeginExecute - port over to .net core
我一直在将 .net 代码移植到 .net 核心 ,有些领域具有挑战性。
一个这样的区域是在 MVC 基本控制器覆盖方法中
protected override IAsyncResult BeginExecute(System.Web.Routing.RequestContext requestContext, AsyncCallback callback, object state)
{
OpsManager.ActiveApplicationId = ApplicationId;
return base.BeginExecute(requestContext, callback, state);
}
I gather than a lot of the old System.Web.MVC is deprecated. How can I "fix" or replace this method?
我认为您正在 Controller
class 上寻找 OnActionExecutionAsync
方法:
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
// Do something...
await base.OnActionExecutionAsync(context, next);
}
或者,如果您想对 所有 请求应用一些逻辑(不仅仅是针对单个控制器),您可能需要查看 middleware.
我一直在将 .net 代码移植到 .net 核心 ,有些领域具有挑战性。 一个这样的区域是在 MVC 基本控制器覆盖方法中
protected override IAsyncResult BeginExecute(System.Web.Routing.RequestContext requestContext, AsyncCallback callback, object state)
{
OpsManager.ActiveApplicationId = ApplicationId;
return base.BeginExecute(requestContext, callback, state);
}
I gather than a lot of the old System.Web.MVC is deprecated. How can I "fix" or replace this method?
我认为您正在 Controller
class 上寻找 OnActionExecutionAsync
方法:
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
// Do something...
await base.OnActionExecutionAsync(context, next);
}
或者,如果您想对 所有 请求应用一些逻辑(不仅仅是针对单个控制器),您可能需要查看 middleware.