how to encrypt a connection string in web.config file?

Answer Posted / anand gopal makwa munger

write the code on web.config file Like below

<configuration>
<appSettings/>
<connectionStrings>
<add name="Connection" providerName="System.Data.SqlClient" connectionString="server=abc\Sqlexpress;IntegratedSecurity=SSPI;DataBase=XYZ"/>
</connectionStrings>
</configuration>

and write the code Behind page(ie .cs File)

ConnectionStringSettings con = ConfigurationManager.ConnectionStrings["Connection"];
SqlConnection conn = new SqlConnection(con.ConnectionString);

Is This Answer Correct ?    0 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of resource manager class in .net.

710


Can we handle the error and redirect to some pages using web.config?

1248


What are resource file and how do we generate resource file?

759


Why is it preferred to not use finalize for clean up?

728


What is difference between view state and session state?

666


What are custom controls?

706


What does mean by a neutral culture?

791


Define tracing.

833


What are query strings used for?

731


Which library is used by the testers and developers to develop automated tests and create testing tools?

744


What is the difference between executescalar and executenonquery?

713


What are the security types in ASP/ASP.NET? Different Authentication modes?

766


What are the benefits of Razor View?

742


What is a uri query?

754


What is windows active directory authentication?

770