开发者

How to access localised resources in an .ashx file?

开发者 https://www.devze.com 2023-01-12 16:30 出处:网络
I have an ashx file which returns a localised message. This is called from an Ajax request. I need to access the Asp.net Resour开发者_开发问答ceManager in the ashx file.Following code worked for me.

I have an ashx file which returns a localised message. This is called from an Ajax request. I need to access the Asp.net Resour开发者_开发问答ceManager in the ashx file.


Following code worked for me.

HttpContext.GetGlobalResourceObject("classKey", "resourceKey") as string;


Any resources in the app should be accessible under the Resources namespace.

For a resource file called LocalMessages.en.resx:

ReturnMsg = Resources.LocalMessages.MyAjaxMessage;

For intellisense to work, make sure app has been compiled once to create the Resources objects from resx files.

0

精彩评论

暂无评论...
验证码 换一张
取 消