C
C#6mo ago
The Don

Environment Variables/Persistent Values in OpenSilver

Dear Community - I am trying to find a way to store and recall user credentials (such as an API key from a back-end or other user-critical data) when using an OpenSilver project, and haven't had much luck. I was wondering if the community could offer an insight on this. What I've tried (without success) : - Environment Variables (Using System.Environment). - User Secrets. - Storing a file in the file system. Thank you, kindly!
7 Replies
jcotton42
jcotton426mo ago
in what way is it not working? the filesystem is definitely the way to go here user secrets isn't writable and env vars aren't a place to dump your stuff
The Don
The Don6mo ago
The Directory.GetCurrentDirectory() method returns "/", and I think the file system resets itself every time you refresh the page. I can't find any evidence that this file system has access to the host hard drive. Also, when I set the environment variable one time, it it returns as null when I launch it a second time.
jcotton42
jcotton426mo ago
Oh, Silverlight app, derp Can you call out to localstorage?
jcotton42
jcotton426mo ago
MDN Web Docs
Window: localStorage property - Web APIs | MDN
The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.
The Don
The Don6mo ago
NuGet won't let me install the packages from it. Anyway I've moved on from OpenSL for the time being. Will give Blazor a fair shot.
Vasil Buraliev
Vasil Buraliev4mo ago
Check the samples here: https://opensilverdemos.azurewebsites.net/opensilvershowcase/release/?20240130#/Net_Framework. I hope that this page will be useful.
The Don
The Don4mo ago
Thank you!
Want results from more Discord servers?
Add your server
More Posts