且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Web服务发现客户端的时区和文化

更新时间:2022-06-20 22:33:29

假设你的客户端连接到Web服务从一个浏览器,就可以使用Request.Headers [接受语言]来检测浏览器的文化settings.It是不可能直接从服务器获取的时区,则需要在客户端上一些JavaScript来计算自己的本地时钟与格林尼治标准​​时间之间的时间差。

Assuming your clients connect to the webservice from a browser, you can use Request.Headers["Accept-Language"] to detect the browser's culture settings.It is not possible to get the timezone directly from the server, you need some javascript on the client to compute a time difference between their local clock and GMT.

如果你的web服务diferently消耗的(即不是从一个浏览器),你将需​​要作为参数添加这两条信息到你的Web服务的方法。

If your webservice is consumed diferently (ie. not from a browser), you will need to add these two pieces of information as parameters to your webservice methods.