Warm tip: This article is reproduced from serverfault.com, please click

ASP.NET Core equivalent for ASP.NET MVC BeginExecuteCore

发布于 2020-11-29 01:44:38

I am migrating from ASP.NET MVC to ASP.NET Core and the later does not have a BeginExecuteCore method in Controller.

Do you know a method in ASP.NET Core Controller that I could use to set Thread.CurrentThread.CurrentUICulture before the Request Action is called?

Questioner
Loaderon
Viewed
0
Loaderon 2020-11-29 09:44:38

After some litle code diving inside of Microsoft.AspNetCore.Mvc package, I found that the class Controller has a couple of methods that help to control the execution of every Request Action.

This are OnActionExecuted and OnActionExecuting. Which run after and before the action execution respectively.

In my case, OnActionExecuting did the trick.