I have several console applications that I'm developing to do various tasks. My usual approach to this is to read the web.config and get the conn string, that way when and if it changes, it won't break my existing console applications. My console apps have a configuration value of the file to read to get the conn string.
I want to do the same with my ac store, i.e., have my console applications read the database.config file in app_data. However, it is encrypted and I want to know what I need to do to decrypt it.
decrypting database.config
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: decrypting database.config
You could store the connection string unencrypted in the global.asax file if you can code against it from there. Here's an example of doing it in one way, but you could put the whole connection string in as a string.
Found by Googling:
You could use Application["ConnString"]= (whole connection string here)
Found by Googling:
Code: Select all
Global.asax.cs
protected void Application_Start(Object sender, EventArgs e)
{
Application["DbUser"]="dbUser";
Application["DbUserPass"]="myPass";
Application["DbName"]="coolDB";
Application["DbServer"]="my.office.db.server";
string myConnString = "Data Source=" +
Application["DbServer"] + ";Initial Catalog=" +
Application["DbName"] + ";User ID=" +
Application["DbUser"] + ";Password=" +
Application["DbUserPass"];
Application["ConnString"] = myConnString;
}
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: decrypting database.config
Give a try and make use of CommerceBuilder.Utility.EncryptionHelper.DecryptAES method by providing it the ciphered string.
Re: decrypting database.config
Thank you for your answers.
I actually found a super simple and very elegant way to accomplish this:
I actually found a super simple and very elegant way to accomplish this:
Code: Select all
VirtualDirectoryMapping vdm = new VirtualDirectoryMapping(@"C:\www\myAbleCommerceSite", true);
WebConfigurationFileMap wcfm = new WebConfigurationFileMap();
wcfm.VirtualDirectories.Add("/", vdm);
Configuration config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
string connStr = config.ConnectionStrings.ConnectionStrings["AbleCommerce"].ConnectionString;