C
C#2y ago
Servator

App.Config vs Resources.resx [Answered]

What's the main difference between them also why App.Config considered more secure approach ? 2nd question: Can i store type values with App.Config like ConsoleColor.Red ?
8 Replies
Servator
Servator2y ago
bump
Mayor McCheese
app.config would store settings about your application from an execution standpoint, it's not particularly secure, especially for a client app. You have prebuilt structures for things like connection strings A resource file is typically used to store information about your application from a usage perspective, label fields, etc. There is a whole system for resource files in different languages for instance.
Servator
Servator2y ago
Also there is AppSettings I am really confused about those What would you prefer ?
Mayor McCheese
AppSettings.json? App.Config is pretty rigid and in code has a lot of static helper classes, I don't personally like it, people tend to use ConfigurationManager class like it's going out of style and I think it promotes bad coding practices.
Servator
Servator2y ago
There is type safety issue too
Mayor McCheese
for example:
class Something
{
string GetData()
{
var value = ConfigurationManager.AppSettings["SomeKey"];
return value;
}
}
class Something
{
string GetData()
{
var value = ConfigurationManager.AppSettings["SomeKey"];
return value;
}
}
I have no way to track usage of "SomeKey", other than searching code. I always advise not to use something like ConfigurationManager directly, but to build facades over it with AppSettings.json this is much easier to do.
Servator
Servator2y ago
ok thanks
Accord
Accord2y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server
More Posts
Using multiple RateLimiters correctly. [Answered]I'm wrapping an API which requires no more than 4 requests per second **and** 200 per hour, I've gotAbstract List of KeyValuePairs```cs public abstract List<KeyValuePair<string, int>> inventory;``` It says I can't do this with a fMAUI navigation to new page with injected viewModelIf you think this belong more into #mobile channel I can move, but I think some of you who are morecatching an exception in an async Task [Answered]I can't seem to catch an exception that is thrown in an async Task, I put try/catch within the asyncpass data onclick from one page to another page in asp nethi all, im trying to redirect a page from **Main Page** to **Sub Page** when i click an item on **MASP NET Core default DI-Container, how pass in constructor not-registered parameter? [Answered]I want to create a Model class using a DI container, services registered in the container are passedShould I return the whole created object in POST or just return the id of that object ?When I creating a post method I find myself repeat what I did in GetById Should I just return the Iasp net cshtml javascript filehi all, i have an asp net project (SimpleApp) and in a cshtml file of my **SimpleApp ** project i trChange Visual Studio suggetions with custom analysersHiya.. ohh discords new "forum" channels are super useful for this huh?. anyway. So I managed to impProgram won’t run with just .net runtime [Answered]So my program that I published and is targeting .net 6 won’t run when the pc has just .net 6 runtime