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

how to handle sql exceptions?

4 Answers   Marlabs, TCS,


What is web api vs wcf?

0 Answers  


what exception is thrown when you do a response.redirect

2 Answers   IBM,


How do you pass session values from one page to another ?

4 Answers   Digital GlobalSoft,


What namespaces are imported by default in ASMX files?

2 Answers  






What are the different types of Session state management options available with ASP.NET?

1 Answers  


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

0 Answers  


Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?

2 Answers   Siebel Systems,


Asp pages that worked pefectly on windows 2000 server and iis 5.0 do not work on windows 2003 server with iis 6.0. Asp.net pages work fine. Why?

0 Answers  


What is application variable in asp.net?

0 Answers  


Where is the session stored?

0 Answers  


What is CLR ? Differentiate between CLR & CTS.

7 Answers   3i Infotech, TCS,


Categories