which method marks a config file section for encryption?



which method marks a config file section for encryption?..

Answer / guest

protected void Page_Load(object sender, EventArgs e) {
Configuration config;
ConfigurationSection configSection;
config = WebConfigurationManager.OpenWebConfiguration
(Request.ApplicationPath);
configSection = config.GetSection("connectionStrings");
if (configSection != null) {
if (!(configSection.SectionInformation.IsLocked)) {
configSection.SectionInformation.ProtectSection("
DataProtectionConfigurationProvider");
config.Save();
} } }


To unprotect :

Public Sub Page_Load()
Dim config As Configuration
Dim configSection As ConfigurationSection
config = WebConfigurationManager.OpenWebConfiguration
(Request.ApplicationPath)
configSection = config.GetSection("connectionStrings")
If Not (configSection Is Nothing) Then
If Not (configSection.SectionInformation.IsLocked) Then
configSection.SectionInformation.UnprotectSection()
config.Save()
End If
End If
End Sub

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Whats the difference between abstract factory pattern and factory pattern?

1 Answers  


Compare and contrast between inline and code behind - which one is best?

2 Answers   Siebel,


Explain in what order a destructors is called.

1 Answers  


How do you implement Paging in .Net ?

1 Answers  


How to write test case (Unit test plan)

1 Answers   Syntel,


Explain what benefit does your code receive if you decorate it with attributes demanding specific security permissions?

1 Answers  


About Global .asax ?

6 Answers   Satyam,


What is asp.net and how it works?

1 Answers  


Define WCF ABC , Diffrent Contract. Diff b/w Wcf and in webservice

2 Answers   Syntel,


Types of object in asp ?

1 Answers   Accenture,


WHAT IS BOXING? HOW WE CAN USE IT?

4 Answers   Seion Infotech,


Explain what is postback in asp. Net?

1 Answers  


Categories