Raja Afrika of the Afrika 8
Thursday, April 25, 2024
 
Back to Raja's Blog

Raja's Blog
Not All Who Wander Are Lost

Microsoft Lightswitch 2015 Reading Web.Config and App Settings
Posted: Friday, April 24, 2015

I recently spent 4 very frustrating hours trying to do something that I thought would be very simple. I just wanted to read the ApplicationID out of Web.Config.

I am using ASP.NET Identity and I want to be able to filter my data based on the currently logged in client. So I search for:



  • LightSwitch 2015 read web.config



  • LightSwitch 2015 read ApplicationID



  • Lightswitch Global Variables




 Nothing.

Then I stumbled across the following article


  


How to: Store and Retrieve Application Settings Using Isolated Storage


 Silverlight


https://msdn.microsoft.com/en-us/library/cc221360(v=vs.95).aspx 


Bottom Line: You can use Isloated storage like a global variable that you set at application initilization and then call from your event code.

Private appSettings As IsolatedStorageSettings =IsolatedStorageSettings.SiteSettings

Private Sub MyScreen_Activated() Sub SearchClients_Execute()
 ' Write your code here.
appSettings.Remove("ApplicationID")
appSettings.Add("ApplicationID", "MyGlobalValue")
End Sub

Private Sub SearchPatients_Execute()
Dim ApplicationID As String = appSettings("ApplicationID")
End Sub

According to the article:

You can use isolated storage in Silverlight to store application settings, which are per-application, per-computer, and per-user settings. Their scope is determined by the full path of the application .xap file. For example, you can store application settings, such as number of images to display per page, page layout customization settings, and so on.

You store application settings using isolated storage by using members of the IsolatedStorageSettings class. This class implements a dictionary that is designed to store name/value pairs. Like all data stored in isolated storage using Silverlight, application settings are stored locally on the user's computer. In Windows 7, the information is stored in the AppData\LocalLow directory. For other operating system versions, including those on the Apple Macintosh, information is stored in the AppData\Local directory. Values stored in isolated storage are stored locally and are not available for roaming.