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
What is a nested masterpage in asp.net 2.0? Can there be a master page inside a masterpage?
How to display validation messages in one control?
What is the use of session in web application?
What is the difference between user control and custom control?
Define a web service in .net?
What is asp.net version?
What are Master Pages in ASP.NET? or What is a Master Page?
What are the differences between code behind and code inline?
What is the difference between trace and debug in asp.net?
What are the benefits of view state?
what are the security certificates used in webservices?
How about the security in Activex DLL and Activex EXE ?
Explain the Session state management options available with ASP.NET?
Define static function?
Is asp.net free?