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 the latest version of asp.net?

537


Can anyone please tell me that the question posted on this website are Sufficient for the interview with 2+ year experience in .net

1505


What is the difference between localization and globalization?

561


What is inheritance and an how it be used, example with an example?

586


Is it possible to migrate visual interdev design-time controls to asp.net?

563






while developing webservices if i want some users to use my webservice only how can i give security to my webservice?

1409


What is windows active directory authentication?

570


Can a .net web application consume java web service?

512


Define static member?

537


Define msil.

551


What is the difference between asp.net and mvc?

585


What is cookies in asp net?

523


Is asp.net mvc still used? : Asp.Net MVC

513


What is difference between view state and session state?

481


How does u get record no from 5 to 15 from a dataset of 100 records?

515