Replace resources.resx with key vault values - .net-core

I have a .net core mvc project that has the relevant appsettings.json file which contains a reference to an azure key vault. The project then gets all it's config values from there.
There is another api project in the solution which is a class library. Currently this has a resources.resx file that has some duplicated values in it. Is it possible to replace the resources.resx file with a reference to the key vault instead?

Related

How to implement integrity control of web applications

Any web application (for example asp.net/asp.net mvc) contains many *.dll, *.js, *.css, *.aspx, *.ascx, *.cshtml and other files.
We need to implement mechanism to control integrity of all these files to quickly analyze was modified any file or not after deploy.
So, we can on continuous integration server generate file with hashes of all files, put it into some dll of project as embedded resource, and sign dll via strong name. Then in every time we can check integrity of dll and validate hash of all files.
Is there a more simple solution? Or ready to use third party solution?

What is the alternate of web.config file in asp.net core

I am started working on asp.net core web application and there is no web.config file in this project. Here is appsettings.json file though. I don't know where to store confidential information (like we store username and passwords of domain in web.config file in .Net Framework). Is it safe to Store confidential data in appsettins.json file?
Yes appsettings.json is like web.config for ASP.NET Core. It’s for storing non secretive data. But there are multiple ways to configure your app, e.g. environment variables, command line arguments, as well as appsettings.json. You can also configure each environment with this file.
You should not store secrets like usernames, passwords or API keys here, as this file gets checked into source control and you might leak these to other parties. You can use User Secrets (only in development) or Azure Key Vault for secretive settings.
This is a big topic so it’s better to check the docs on this, and see which provider(s) works best for your scenario.

WCF Service Library Won't Accept System.Web Reference

I have a WCF project service library that is receiving an encrypted username and password. I need to encrypt my response back to the requested user. I created a separate service library and add the encryption methods in it. Because I am using System.Web.HttpUtility.UrlEncode(EncryptUser(key, user),
Encoding.GetEncoding("utf-8")), I need to add a reference to System.Web dll. However, adding the reference to System.Web causes an issue with the WCF Service. Every time I compile, it says that the reference to USER.dll is not found. If I remove the reference to system.web dll, the WCF Service is not complaining, but I am getting a message "HttpUtility does not exist in the other project are you missing a reference?"
How do I get around this given it is specified in the requirement that I use System.Web.HttpUtility.UrlEncode?
The issue is fixed after going to the WCF project's property and change the target Framework to .NET Framework 4.

How to get RESX value from other project in the same solution

I have two projects in the same solution:
My.Solution.name.with.dots
BLL
Web
in the BLL project, I create a class that need to get a global resx value from RESX file that is placed in the Web project. Is it possible ?
BLL can't have a reference to Web project because of the project dependency
The resource, as an accessible class, is part of your web dll. I would be better to move your resource to a separate project that both libraries can access.
Alternatively have a play with the ResXReader to read a resource file from a specific location.

ASP.NET plug-in architecture, settings problem

I want to divide business layer (BLL) of an asp.net application into multiple components. Each component is a .NET class library which is compiled as a standalone DLL. These components should have their own configuration files. For example "MyNameSpace.Users.dll" contains classes about users of the website and there's a password policy to check if password length is at least x characters. When webmaster edits the config file of this DLL and set x to y then component (DLL) should use new value (y) in the future and enforce passwords to be at least y characters. I want each component as a single project and compile them separaely (and not to put all projects in a solution in Visual Studio), and put the DLLs of these libraries into the "Bin" folder of my ASP.NET application.
Is it possible ?
Where should I put these config files ?
Managed Extensibility Framework (MEF) released in .NET 4.0
http://mef.codeplex.com
imho It's possible but not out of the box.
ASP.NET uses by defautl only the one web.config in the web root (and pproriate machine .config files higher up in the hierarchy). But you can create custom settings providers for each of your dlls that read values from separate .config files.
see http://msdn.microsoft.com/en-us/library/ms228060.aspx
This way you create different SettingsManager providing settings to parts of the App and reading the info from files.
Plus you can use FilesystemWatcher to reload values when the additional .configs are edited.

Resources