Thread.CurrentThread.CurrentCulture and ajax

If I set Thread.CurrentThread.CurrentCulture to PageLoad , when I call the codebehind method, I find the culture that I set to PageLoad , BUT if I call [WebMethod] with $.ajax() , the culture is the default by default and not that which I installed in PageLoad .

I assume that since the two calls are in two different threads.

I wonder if there is a way to establish a culture in order to find it in both situations.

+4
source share
2 answers

If different page loads may have different cultural information; then you may have a problem. WebMethod does not know which page uses this method (or whether the page used it at all is just a web service method, anyone could call it).

I would suggest sending back information about the cultural invariant, and then specify the page format for the information that it knows about.

Otherwise, you may have to pass the culture information to the web method.

+4
source

Setting Thread.CurrentThread.CurrentCulture at the beginning of WebMethod worked for me

-1
source

Source: https://habr.com/ru/post/1434378/


All Articles