How to keep private data separate in an open source ASP.NET MVC application -


I am working in an open source ASP.NET application, I need to keep certain data in the configuration file, While still people make it easy to create and debug it on their machine. It has data like API keys, mail settings, etc.

How do I keep this data different and out of the GIT repository, while still allowing people to just drag and install without bunch

You can define configSource in your config file:

  & lt; Configuration & gt; & Lt; AppSettings configSource = "filepath1.config" /> & Lt; ConnectionStrings configSource = "filepath2.config" /> & Lt; -! Etc. - & gt; & Lt; / Configuration & gt;  

Keep the configurations that you need to keep private in the private config file, then exclude them in your .gitignore.

Keep in mind that it will completely ignore the section and overwrite it with your reference in the referenced file.

You can also do that, which allows you to overwrite only the squares in the variables of a small set. For example:

In your main Web.config:

  & lt; Configuration & gt; & Lt; AppSettings & gt; & Lt; Add key = "key1" value = "nothing that I do not care" /> & Lt; Add Key = "Key 2" value = "Some Dummy" /> & Lt; / AppSettings & gt; & Lt; / Configuration & gt;  

And in your web Release.config:

  & lt; Configuration xmlns: xdt = "http://schemas.microsoft.com/xml-Document-Conversions" & gt; & Lt; AppSettings & gt; & Lt; Add key = "Key2" value = "something I want to keep secret" xdt: Transform = "SetAttributes" xdt: Locator = "Match (key)" /> & Lt; / AppSettings & gt; & Lt; / Configuration & gt;  

In this case the "key 2" value that you want to keep private will be in a separate file, and you can remove the web. Rege.Gotignore.config

Besides, I never tried, which can overwrite the installation using external files.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -