Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Returning a Razor View runs in a new Thread

$
0
0

Hey,

I'm writing an MVC Core app which I've hand cranked my own localisation system (I'm doing things beyond the scope of the standard core one) which uses request filters etc to set various bits of information.

If I place a breakpoint in the controller action on the return View line, I can use the immediate window and see that the current thread's culture is set to what I expected (i.e. the one I set in my filter using the bog standard implementation below...

  cultureName = CultureHelper.GetImplementedCulture(cultureName); 

  // Modify current thread's cultures            
  Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName);
  Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;       

This all works fine however if I step into the Razor view and perform the same check, the culture has been dropped and set to the default culture. Is there any reason for this or is this a bug? Is there any way to keep the same culture (as it did in the none Core version).

Dave


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>