Archive for June, 2013

ExecuteCore not called in ASP.NET MVC 4

If you want a function to be called before every page load in an MVC web application, then you could of course call that function from every action, or you can override the ExecuteCore method.

But no… It never gets called, what can you do?, well, I discovered on StackOverflow, that if you also override¬†DisableAsyncSupport and return true, then the ExecuteCore method gets called



protected override void ExecuteCore()
// Modify current thread’s cultures
var strCulture = CurrentLocale();
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(strCulture);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;


/// <summary>
/// Ensures that ExecuteCore() is called.
/// </summary>
protected override bool DisableAsyncSupport
get { return true; }

This is how, I’ve created two code-identical sites, and with different resource files to handle two different locales

Categories: Uncategorized
%d bloggers like this: