Hi,The below is the connection string in Web.Config File.<connectionStrings><add name="DBConnectionString" connectionString="Data Source=localhost;Initial Catalog=Master;User ID=sa;Password=t1234@asd" providerName="System.Data.SqlClient" />We are Using Inproc Session:<sessionState mode="InProc"cookieless="false"timeout="1440"/>I need to Encrypt and Decrypt ConnectionString.Example:I seacrh in google , So i tried with RSAProtectedConfigurationProvider. when i encrypt the file in web.config , the connectionstring is encrypted.Configuration confg =WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);ConfigurationSection configSect = confg.GetSection("connectionStrings");if (configSect != null){configSect.SectionInformation.ProtectSection("RSAProtectedConfigurationProvider");confg.Save();}Above code is i copied in Login_Click Event , when the user gives username and pwd and click the button.If successfull user redirecting to the page.Response.Redirect("Sample.aspx");It redirecting to Sample.aspx page , but the session null again redirecting to Home.aspx.In Sample.aspx page:public void Page_Load(){if (Session[USER_NAME] == null){Response.Redirect( Home.aspx");}else{}Why Session is Null? Can you please suggest me how to secure that connectionstring and users have to access my site without any problems.Thanks,Suresh
Hi,
The below is the connection string in Web.Config File.
<connectionStrings><add name="DBConnectionString" connectionString="Data Source=localhost;Initial Catalog=Master;User ID=sa;Password=t1234@asd" providerName="System.Data.SqlClient" />
We are Using Inproc Session:
<sessionState mode="InProc"cookieless="false"timeout="1440"/>
I need to Encrypt and Decrypt ConnectionString.
Example:
I seacrh in google ,
So i tried with RSAProtectedConfigurationProvider.
when i encrypt the file in web.config , the connectionstring is encrypted.
Configuration confg =WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection configSect = confg.GetSection("connectionStrings");
if (configSect != null){configSect.SectionInformation.ProtectSection("RSAProtectedConfigurationProvider");confg.Save();
}
Above code is i copied in Login_Click Event , when the user gives username and pwd and click the button.
If successfull user redirecting to the page.
Response.Redirect("Sample.aspx");
It redirecting to Sample.aspx page , but the session null again redirecting to Home.aspx.
In Sample.aspx page:
public void Page_Load(){if (Session[USER_NAME] == null){Response.Redirect( Home.aspx");}else{
Why Session is Null? Can you please suggest me how to secure that connectionstring and users have to access my site without any problems.
Thanks,
Suresh