与页通过AJAX方法/ Web服务ASP.NET本地化 [英] ASP.NET localization with Page Methods/Web Services via AJAX

查看:113
本文介绍了与页通过AJAX方法/ Web服务ASP.NET本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个拗口......

That's a mouthful...

下面是个问题,我们正在做一些客户端验证通过AJAX调用页面方法(本质上属于网络服务)。我们还添加了网页上的下拉列表中选择你的语言,并创建了一个继承自Page初始化基础上,下拉选择定位。当网页的方法越来越通过AJAX叫虽然,该页面无法正常初始化,因此本地化的初始化没有发生。

Here's the issue, we're doing some client-side validation via AJAX calls to page methods (which are essentially web services). We've also added a drop-down on the page to choose your language and have created a class that inherits from Page that initializes localization based on the drop-down selection. When page methods are getting called via AJAX though, the page isn't instantiated normally and therefore the initialization of localization isn't taking place.

我认为储蓄语言选择会话,但这并不能解决问题,因为每个页面的方法将不得不为了得到装载了适当的语言文件重新初始化定位。关于如何处理动态本地化页面方法或Web服务有什么想法?

I've considered saving language choice to the session, but that doesn't solve the problem as every page method would have to re-initialize localization in order to get the proper language files loaded. Any thoughts on how to deal with dynamic localization in Page Methods or Web Services?

这是我们第一次涉足本地化,所以我希望我失去了一些东西很明显...

This is our first foray into localization so I'm hoping I'm missing something obvious...

推荐答案

我不知道为什么你experencing这个问题,但是一个简单的解决办法是简单地传递在语言环境中的AJAX调用页面方法或Web服务。

I'm not sure why you're experencing this problem, but one easy solution would be to simply pass in the locale in the ajax call to a page method or web service.

我在我的应用程序所做的设置与区域设置一个cookie。我做我的自动完成的Web服务是简单地调用来自我所有的公共Web服务方法code以下行: LavaBlastBasePage.SetCultureFromCookie();

What I did in my application was to set a cookie with the locale. What I do in my auto-complete web service is simply call the following line of code from all my public web service methods: LavaBlastBasePage.SetCultureFromCookie();

这是类似于使用会话,但是。

This is similar to using the session, however.

这篇关于与页通过AJAX方法/ Web服务ASP.NET本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆