Configuration is difficult, and confusing, and one of the first things to become a difficult thing to deal with once a project really starts to grow. Before you know it you have to store connection strings, api keys for multiple dependencies, logging settings and so on.
Comparing the current situation with how it was back in the days of the .NET Framework, I think it has really improved. Now we have the
appsettings.json files in which we can put everything we like, and which we can easily query by injecting the
What was not clear to me was how to share a single configuration file with all the individual projects within a solution, and that’s exactly what this post is about!
I have no idea whether these are best practices. Personally I’m just looking for a way by which I can keep my configuration maintainable in a larger solution, where most of the projects have somewhat the same configuration. I haven’t really worked with secret configurations, and I know that it’s been discouraged to store secrets within configuration files, but that’s what I’ve been up to now, and that’s probably how I’ll be doing it until someone points me to a fairly straightforward way to maintain it all.
The code produced in this blog post is published on GitHub as being a stand-alone library you can include in your project. The library itself can handle most of the email delivery needs, while you can bring your own views and view-models. Samples are available within the repository.
You can find the package on NuGet over here.
Sending transactional email from my applications has always been one of my weakest points. Developing applications is easy. Writing api’s is just an everyday task, and even utilizing raw sockets to implement some obscure real-time api is considered trivial when it comes to sending transactional emails from an application. I have been actively writing software for about nine years now. Professionally for about five. But email? Email is still one of the things I actively try to avoid. Emails are a true pain in the ass, at least for me. Doing a quick google search on sending emails with .NET yields plenty of results and blog posts, but none of them really usefull. They are all about how to use the SMTP protocol from within C#, and that just does not cut it for me. The solutions are not reusable, promote a shattered software architecture, and are in no way maintainable, nor usable in the first place.