which method marks a config file section for encryption?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Razor View Engine

821


What are the main differences between asp and asp.net?

738


If 200 is for all successful operation then why do we have 201 response codes?

710


What is preprocessor in .net?

706


What is the use of view state?

718


Explain in what order a destructors is called.

787


Can I stream live content/events?

785


How would you turn off cookies on a page of a website?

678


What are early binding and late binding.

821


Define the term Scavenging in Caching?

776


What does session_start () do?

823


What is the difference between CC and BCC?

805


How may clustered index we can create in table?

748


Fetch one page value to another page without using state-managment ?

703


What does asax stand for?

739