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 command line compiler.what are the steps and how it is related to debugging.

1409


What is datagrid asp.net?

491


What is application and session in asp.net?

530


What is the file extension of web service?

551


To wrap up a call to a Web service the standard used is..?

536






What is a postback ispostback and autopostback in asp net?

473


Explain the difference between AutoPostBack and IspostBack in ASP.NET?

596


Which is better viewstate or session?

513


Explain how asp.net different from asp?

553


How does session work in asp net?

552


Define web.config in .net?

633


What are the authentication types in asp.net?

569


What is the difference between executescalar and executenonquery?

508


What is asp.net and its advantages?

547


what are the ihttphandler and ihttphandlerfactory interfaces ?

509