Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net localization of text in webservice method

When I want to localize code behind of page I use this

HttpContext.GetLocalResourceObject(path, message)

My question is that, is there a way to use local resources of page inside webservice methods?


1 Answers

you can't use HttpContext.GetLocalResourceObject instead of that use HttpContext.GetGlobalResourceObject

Global Resource Files

You create a global resource file by putting it in the reserved folder App_GlobalResources at the root of the application. Any .resx file that is in the App_GlobalResources folder has global scope. Additionally, ASP.NET generates a strongly typed object that gives you a simple way to programmatically access global resources.

Local Resource Files

A local resources file is one that applies to only one ASP.NET page or user control (an ASP.NET file that has a file-name extension of .aspx, .ascx, or .master). You put local resource files in folders that have the reserved name App_LocalResources. Unlike the root App_GlobalResources folder, App_LocalResources folders can be in any folder in the application. You associate a set of resources files with a specific Web page by using the name of the resource file.

like image 144
Damith Avatar answered Dec 14 '25 19:12

Damith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!