Tips Station Asp.net Article Seo Articles
Tutorials Code Samples
›  Home
›  Mission
›  About us
›  Contact Us
›  Feedback
›  Terms & Condition
Asp Articles
IT Solutions
 
› ASP.NET

› Programming Tips

› Ajax

› Asp

› ADO.NET

› Databases

› SEO

› CSS And Designing

› Php

 
Most Viewed Articles
 
› Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

› Change theme dynamically without page refresh in ASP.NET

› Install AJAX On Machines Running Visual Studio 2005

› Creating Pretty Popups Using AJAX

› Simple ASP Image Resize Function

› SQL Server Performance Counters

› ASP.Net Interview Questions And Their Answers

› Encode Url using ASP

› Difference Between DataGrid and GridView in Asp.Net

› Select Specific Value WithIn Drop Down List Or Radio Button List

more...
 
 
Home> Programming Tips
 
Encrypt Applications Settings in Asp.Net
 

Encrypt your connections strings and application settings in code
You can encrypt the appSettings and connectionStrings sections of your web.config file via code when your application first starts. To do this, create a file named "global.asax" in your root directory and add this code to Application_Start method.

   <%@ Application Language="VB" %>  
    <%@ Import Namespace="System.Configuration" %>  
    <%@ Import Namespace="System.Web.Configuration" %>  
      
    <script runat="server">  
      
        Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)  
           ' Code that runs on application startup  
             
           ' Get the file path  
           Dim path As String = HttpContext.Current.Request.CurrentExecutionFilePath  
           path = path.Substring(0, path.LastIndexOf("/"))  
     
           ' Get the appSetting and connectionStrings sections  
           Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(path)  
           Dim appSettings As ConfigurationSection = config.GetSection("appSettings")  
           Dim connectionSettings As ConfigurationSection = config.GetSection("connectionStrings")  
             
           ' Encrypt the appSettings and connectionStrings sections if they are not already protected  
           If appSettings.SectionInformation.IsProtected = False Then  
               appSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")  
               ' To unprotect this section, use:  
               'appSettings.SectionInformation.UnprotectSection()  
           End If  
           If connectionSettings.SectionInformation.IsProtected = False Then  
               connectionSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")  
               ' To unprotect this section, use:  
               'connectionSettings.SectionInformation.UnprotectSection()  
           End If  
             
           Try  
               config.Save()  
           Catch ex As Exception  
               ' If an error occurs, it is most likely a permissions error  
               ' so make sure the ASP.NET process account has write permissions for the web.config file  
           End Try  
       End Sub  

 

 
 
Vrp Technologies
 
Serversea Hosting
 
 
Latest Articles
 
› Sending SMS With PHP

› MySQL Join Tutorial

› Make An RSS Feed Using PHP

› Intro To Object: Option Variables

› Design An Online Chat Room With PHP And MySQL

› Create Tell A Friend Script With HTML & PHP

› Benchmark And Optimize PHP Script Speed

› What Kind of DBA Are You?

› SQL Server Performance Counters

› SQL Server Performance Tips

more...
 
Random Articles
 
› Top 10 Best Practices for Production ASP.NET Applications

› Read and display a text file in Asp.net

› Displaying Data using ASP.NET 2.0 GridView

› SubRoutines vs. Functions - ASP

› Displaying an RSS Feed using ASP

› Design Considerations for Cross Page Post Backs in ASP.NET 2.0

› What Are Active Server Pages (ASP)?

› Clear all TextBox values in Asp.Net

› Cache Data within your Application - Asp.Net

› Difference Between DataGrid and GridView in Asp.Net

more...
 
Home Mission About us Contact us Feedback Terms Conditions
2008 © Copyright TipsStation. All rights reserved.