Writing Encrypted Connection String To Web Config File?
Jun 28, 2011How to programmatically write an encrypted connectionString to a Web.Config file?
View 5 RepliesHow to programmatically write an encrypted connectionString to a Web.Config file?
View 5 RepliesI have written the web.config for same server without username and server and its working.
but not been able to provide the username and password in web.config file.
Following is my web.config for Server:
[Code]....
I have to write another web.config for client application with username and passoword. how could i use it.
server name is "BM", User is "Sa" and Password is "abc"
How to run asp.net application with encrypted web.config ,is it possible note that ASP.NET application have a database with encrypted connectionstring and a "cannot read connection string " message is generated
View 2 Repliesjust for my testing purpose i know i can define both the connection's outside in a single web config file by different name's and access them in my front end according to it but what if i want to have seprate for both connection's web.config situation is like this see image so i want to access my connections from second web config file how i can do that.
[Code]...
i tired this but its giving error
[Code]....
how to write connection string in app.config file in vb.net windows application and how to call connection string in forms
View 2 Replieswhy we use connection string in web.config file??? Or what is the benefit of using connection string in web.config file?
View 7 RepliesI am having trouble connecting to a ms sql database on the server. The hosting company said that the .sql file was imported successfully, but when I try to use the 'login' or 'create account' features im getting an error page saying:
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. make sure the user has a local user profile on the computer. The connection will be closed.
I am sure all the connection info is correct so it is really frustrating trying to work the problem. I have listed the connection string in my web.config file to see if anyone can see anything wrong with it.
I have this in the web config file <connectionstrings> section. Why is there an add and then remove and then again an add...what is it trying to accomplish here? and in the second code section, I use that string in a sqldatasource control. Second question: Can I just use the name attribute value "localsqlserver" form web config file, in place of the connection string in the data source? is it why that attribute is for?
[Code]....
My requirement is to save the connection string of database that will be provided to be me by user on form, which can be modified lator.
i need to know how and where i should store the connection string permanently which will be used lator to connect to database.
I have a db connection string 'ApplicationServices' defined in the connectionString section of web.config and 3 Entity Framework connection strings which have the provider connection string attribute with the same connection string as the one in 'ApplicationServices'. Is there a way to reference connectionString in 'ApplicationServices' for the provider connection string attribute of the EF connection string in the web.config, rather than providing the connection string all over again?
View 1 RepliesI'm running into a really annoying problem with my Linq to SQL project. When I add everything in under the web project everything goes as expected and I can tell it to use my existing connection string stored in the web.config file and the Linq code pulls directly from the ConfigurationManager.
This all turns ugly once I move the code into its own project. I've created an app.config file, put the connection string in there as it was in the web.config but when I try to add another table in the IDE keeps forcing me to either hardcode the connection string or creates a Settings file and puts it in there, which then adds a new entry into the app.config file with a new name.
Is there a way keep my Linq code in its own project yet still refer back to my config file without the IDE continuously hardcoding the connection string or creating the Settings file? I'm converting part of my DAL over to use Linq to SQL so I'd like to use the existing connection string that our old code is using as well as keep the value in a common location, and one spot, instead of in a number of spots.
Manually changing the mode to WebSettings instead of AppSettings works untill I try to add a new table, then it goes back to hardcoding the value or recreating the Settings file. I also tried to switch the project type to be a web project and then rename my app.config to web.config and then everything works as I'd like it to. I'm just not sure if there are any downfalls to keeping this as a web project since it really isn't one. The project only contains the Linq to SQL code and an implementation of my repository classes.
My project layout looks like this
[code]....
Every time I try to make the default constructor look like the first way, it always auto changes back to the second way once I make a change to the file unless the DBML is inside of a web project.
I will explain the my current yet simple architecture of my application(s). At the moment I have my main web application as a separate project. I then reference the CoreBLLDAL (Business Logic and Data Access) Project so that several projects can have access to the BLL/DAL Project.
Within the CoreBLLDLL Project I use TableAdapters for my DAL.
I have just upgraded to VS2010 and I would like to make use of the Config Transforms, allowing me to have a separate web.config for test and production - however, TableAdapter get the connection string from the Settings.settings file.
How can I change the TableAdapters to get the connection string from the app/web.config file? I read that you can change this within the designer file for the TableAdapters by using ConfigurationManager, however, I tried this but I do not have access to the ConfigurationManager namespace. I presume this is because the project is a class library and not a web application - I am not too sure.
Is aspnet_regiis.exe secure? If i encrypt using aspnet_regiis.exe, will it automatically decrypt the string and wont give any error? Need an insight into this stuff.... Is Rsa the best option or wat? Wat's the best way to encrypt/decrypt programmatically?
View 10 RepliesHow can encrypt the web configuration file ... so I don't want the connection name is appeared. How to do ncryption of web config file.
View 1 RepliesI want to encrypt my web config when i deploy it to server so that the username and password of database is secured. I've tried some of the encryption and it did'nt work. here is my code.Â
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
[Code].....
i don't know how to use a Encrypted ConnectionString with RoleManager in ASP.NET This is code in Web.config.Â
<connectionStrings>
<add name="strConnectionString" connectionString="eF8w9r2UJOsk0Ps3pxmV7/Fy/xPR2hN2S7BrC1iOYNnAUaI8AqkSm5bw7r+ta4sePWSV9t/3Spnpz6wsFpvMmcppNpqM5Zk7iiDqWVgIV4k="/>
</connectionStrings>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
[Code] ....
And in project I create a library to read web config
 private const string ConnectionStringKey = "strConnectionString";
private readonly string SQLConnectionString =
Security.DecryptString(ConfigurationManager.ConnectionStrings[ConnectionStringKey].ConnectionString);
if I change my ConnectionString like this, it's working:Â
<add name="strConnectionString" connectionString="server=My-PCMSSQL2008; database=MyDB; uid=sa; pwd=passw0rd;"/>
But I want my ConnectionString Encrypted so i use
 <add name="strConnectionString" connectionString="eF8w9r2UJOsk0Ps3pxmV7/Fy/xPR2hN2S7BrC1iOYNnAUaI8AqkSm5bw7r+ta4sePWSV9t/3Spnpz6wsFpvMmcppNpqM5Zk7iiDqWVgIV4k="/>
So when i running website it throw error:
System.ArgumentException:Keyword not supported: 'eF8w9r2UJOsk0Ps3pxmV7/Fy/xPR2hN2S7BrC1iOYNnAUaI8AqkSm5bw7r+ta4sePWSV9t/3Spnpz6wsFpvMmcppNpqM5Zk7iiDqWVgIV4k='.
Line 46: string[] roleNames;
Line 47: roleNames = Roles.GetAllRoles();
My aim is to make the web.config not readable by external users, but my application should be able to access it. Is there any way to do this?
I have tried the following way, but how to set the application to use string instead of web.config?
I want to encrypt my web.config file so that others do not open the file using any editor like notepad. But my application should be able to use the same web.config file. I could encrypt the web.config file and decrypt it inside the application and I saved the entire web.config to a string file. Now I want to use this string variable instead of web.config(now in encrypted form, which cannot be accessed by the application).
I have a encrpted web.config file. How to decrypt this file. Because I need to update connection string information in that file. So i need to decrypt the existing encrypted config and update the connection string then again I have to encrypt.Did not work below command. getting error(Decrypting configuration section...Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error mess
age from the provider: Bad Data.)
aspnet_regiis -pdf "connectionStrings" <physical path of the we b.config file in server>
I encrypted my web.config file and I copied this file to the production server. But I get an error. But without encrypting - it's ok. I used:
C:WindowsMicrosoft.NETFramework64v4.0.30319aspnet_regiis -pef "appSettings" "C:inetpubwwwrootSite1" -prov RsaProtectedConfigurationProvider
I don't have access to IIS. Is it possible to encrypt config file and everything works?
I encrypted my connectionstring and store at web.config file. Then I bind Gridview with sqldatasource control, cannot bind because of sqldatasource don't know the(encrypted) connectionstring.
View 5 RepliesI am preparing for an Access2007 db conversion at the beginning of the year and would like to know what the best process would be for connecting to the sqlserver2005 database. I have read about adding the connection string to the web.config file. I have also read about using ADO.NET and put the connection information into a class and not the web.config file.
I would like to hear from others as to what you have used, are using, or plan on using for a webapp (vs2010), and why so I can get an understanding.
I have deploy my web site, it contains a project!
in MyWeb there are all the aspx page and some entites datamodel, in MyApp there are the class with function like "getter data from DB" and there is a entity data model.
afeter the deploy, I have only the web.config and the connection string for the entity datamodel....it´s run ok, read/write the data on the DB.
The problem is with MyApp.....after the deploy it is a dll file and I don´t have the app.config and the entity inside it don´t run, not read/write nothing on the DB.
There aren´t error or messager but not read/write the data in the MyApp project.
all run on the iis 7
now...the question is:
I lose the connection string (in app.config) after the deploy?
Can I put a entity in the MyWeb and read it in another project (myApp)?
ps: for connect to DB I use not the c# code:
var db=from x in AccessDB.Example select x;
I added a database to my project. When I did so an app.config file was added to my project. (Yes I know I have dangerous info in the connection string. I shall change that but for now I am messing around with test stuff.)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="NyStories.Properties.Settings.storyConnectionString"
connectionString="Data Source=|DataDirectory|story.sdf;Password=driver;Persist Security Info=True"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
</configuration>
I did a google search on how to get the connection string value and found. string sConn = ConfigurationSettings.AppSettings["ConnectionString"]; I am getting a warning that this is obsolete. It has been replaced by ConfigurationManager.AppSettings. Ok Fine. According to the docs, it is also in System.Confiuguration which I already have a using statement for above. But when I attempt to use it, it is not part of the assembly.
My web application has to retrieve database from more then two difference sql server.
for example, one from localhost, one from different server ip.
all firewall setting was finished, but i just dont know how to code and use it.
here is my web.config :
[Code]....
this defines only one database in my localhost.but i need to call different connection strings each time i need.
how do i implement this?
I called the string in my Data layer
string connectionName = System.Configuration.ConfigurationSettings.AppSettings["Connection"].ToString();
now how could call it in SqlConnection con