对于.Net 5下的剃须刀页面(不是MVC),这似乎工作正常public async override Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) { if (context.HandlerMethod.MethodInfo.Name == "OnGet") { // code placed here will only execute if the OnGet() method has been selected } // Triggers the OnGet, OnPost etc on the child / inherited class await base.OnPageHandlerExecutionAsync(context, next);}