Tuesday, April 16, 2019

Jenkins: workspace already mapped issue

Hi there

I get workspace already mapped exception.
I tried manually mapping the same. I got following error.

---------------------------
Microsoft Visual Studio
---------------------------
Error

Access to the path 'C:\ProgramData\Microsoft Team Foundation Local Workspaces\e0f0712e-9d02-405a-bf91-08c40eba6863\Hudson-AE_DISCOVER_PULL_BUILDSCRIPTS_NEW-MASTER-CNST;49747230-854f-4327-807f-728068d5e1f2\properties.tf1' is denied.
---------------------------
OK   Help 
---------------------------

peremptorily solution to the issue is remove all files at "C:\ProgramData\Microsoft Team Foundation Local Workspaces\e0f0712e-9d02-405a-bf91-08c40eba6863\Hudson-AE_DISCOVER_PULL_BUILDSCRIPTS_NEW-MASTER-CNST;49747230-854f-4327-807f-728068d5e1f2\" and map the same location again from visual studio. 

Thursday, December 27, 2012

SQL Server : Stored Procedure vs Function, Truncate vs Delete

Stored procedure vs Function

Stored Procedure Function
Stored procedures are stored in parsed and compiled format in the database. Functions are compiled and executed at run time.
Stored procedures can not be called in SQL statement like Select. Functions can be called in SQL statement like Select.
Stored procedures are usually used for Business logic. Functions are normally used for computations.
Stored procedures can contain DML statements. Functions can not contain DML statements.
Exception can be called in stored procedure by TRY-CATCH Block. Exception can not be used in Function
Stored Procedure may or may not return a value. Function will always return a value & it can be only single value.
Transaction management is possible in Procedure Transaction management Is not possible in Function
A Function can be called inside a stored procedure A stored procedure can not be called inside a function.

Truncate vs Delete
Truncate Delete
Truncate is a DDL command. Delete is a DML command.
We can not specify filter in WHERE clause. We can specify filter in WHERE clause.
Truncate deletes all row from Table. Delete deletes row based on WHERE condition or can delete whole table.
Truncate is faster as compared to delete Delete is slower as compared to Truncate.
No log is maintained for Truncate for rows, Log is maintained for data pages. log is maintained for Delete for each row.
Truncate can not activate a trigger. Delete can activate trigger.
It resets the identity column. It does not resets the identity column.

Note :- Delete maintains a ROLLBACK tablespace which stores data which is deleted, so when you exceute ROLLBACK data is gets back. In case of TRUNCATE table does not maintain such ROLLBACK tablespace therefore it does not return data after ROLLBACK

Friday, December 14, 2012

ASP.NET Basic Page Life Cycle


ASP.NET is a powerful platform for building Web applications. With any platform, it is important to understand what is going on behind the scenes to build robust applications. The ASP.NET page life cycle is a good example to explore so you know how and when page elements are loaded and corresponding events are fired.

Ready, aim, fire!

The requesting of an ASP.NET page triggers a sequence of events that encompass the page life cycle. The Web browser sends a post request to the Web server. The Web server recognizes the ASP.NET file extension for the requested page and sends the request to the HTTP Page Handler class. The following list is a sampling of these events, numbered in the order in which they are triggered.
  1. PreInt: This is the entry point of the ASP.NET page life cycle - it is the pre-initialization, so you have access to the page before it is initialized. Controls can be created within this event. Also, master pages and themes can be accessed. You can check the IsPostBack property here to determine if it is the first time a page has been loaded.
  2. Init: This event fires when all controls on the page have been initialized and skin settings have been applied. You can use this event to work with control properties. The Init event of the page is not fired until all control Init events have triggered - this occurs from the bottom up.
  3. InitComplete: This event fires once all page and control initializations complete. This is the last event fired where ViewState is not set, so ViewState can be manipulated in this event.
  4. PreLoad: This event is triggered when all ViewState and Postback data have been loaded for the page and all of its controls - ViewState loads first, followed by Postback data.
  5. Load: This is the first event in the page life cycle where everything is loaded and has been set to its previous state (in the case of a postback). The page Load event occurs first followed by the Load event for all controls (recursively). This is where most coding is done, so you want to check the IsPostBack property to avoid unnecessary work.
  6. LoadComplete: This event is fired when the page is completely loaded. Place code here that requires everything on the page to be loaded.
  7. PreRender: This is the final stop in the page load cycle where you can make changes to page contents or controls. It is fired after all PostBack events and before ViewState has been saved. Also, this is where control databinding occurs.
  8. PreRenderComplete: This event is fired when PreRender is complete. Each control raises this event after databinding (when a control has its DataSourceID set).
  9. SaveStateComplete: This is triggered when view and control state have been saved for the page and all controls within it. At this point, you can make changes in the rendering of the page, but those changes will not be reflected on the next page postback since view state is already saved.
  10. Unload: This event fires for each control and then the page itself. It is fired when the HTML for the page is fully rendered. This is where you can take care of cleanup tasks, such as properly closing and disposing database connections.
An interesting caveat of the events fired with the loading of a page is the controls within the page and their events; that is, each control has its own event life cycle. The following code provides an example of the ordering of page and a couple control events. The ASP.NET source is listed first and followed by the codebehind source. It is a basic ASP.NET 4.0 Web Form with TextBox and Literal controls. The code does not include all events, but it does provide a subset to give you a feel for how they appear. You should notice the events specified in the individual controls that ties them to code blocks.
<%@ Page Title="Home Page" Language="C#"
MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebPageLifeCycle._Default"
OnPreInit="PreInitEvent" ViewStateMode="Enabled" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent" />
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" OnPreInit="Content_Render">
<h2>
<asp:Literal runat="server" ID="litExample" OnInit="Literal_Init"></asp:Literal>
<asp:TextBox runat="server" ID="txtExample" OnInit="Textbox_Init"></asp:TextBox>
Working with the ASP.NET Page life cycle.
</h2>
</asp:Content>
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebPageLifeCycle {
public partial class _Default : System.Web.UI.Page    {
protected void Page_Load(object sender, EventArgs e)     {
Response.Write("Page_Load<br>");
}
protected void Page_LoadComplete(object sender, EventArgs e)  {
Response.Write("Page_LoadComplete<br>");
}
protected void Page_PreRender(object sender, EventArgs e)     {
Response.Write("Page_PreRender<br>");
}
protected void Page_Render(object sender, EventArgs e)     {
Response.Write("Page_Render<br>");
}
protected void PreInitEvent(object sender, EventArgs e)    {
Response.Write("OnPreInit<br>");
}
protected void Page_Init(object sender, EventArgs e)    {
Response.Write("Page_Init<br>");
}
protected void Literal_Init(object sender, EventArgs e)   {
Response.Write("Literal_Init<br>");
}
protected void Textbox_Init(object sender, EventArgs e)  {
Response.Write("Textbox_Init<br>");
}
protected void Page_InitComplete(object sender, EventArgs e)    {
Response.Write("Page_InitComplete<br>");
}
protected void Page_PreLoad(object sender, EventArgs e)    {
Response.Write("Page_PreLoad<br>");
}
protected void TextBox_Unload(object sender, EventArgs e)    {
// Cleanup
}  }  }
Notice the Unload event does not display anything since the Response object is not available in it, since the page and controls have been fully loaded when this event is triggered. The following lines are displayed on the page when it is loaded:
OnPreInit
Literal_Init
Textbox_Init
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_PreRender

HTML vs XML, Array vs ArrayList,Get vs Post Method,Querystring vs Session

HTML vs XML

HTML is an abbreviation for HyperText Markup Language while XML stands for eXtensible Markup Language.

The most salient difference between HTML and XML is that HTML describes presentation and XML describes content.

The differences are as follows:-

1.HTML was designed to display data with focus on how data looks while XML was designed to be a software and hardware independent tool used to transport and store data, with focus on what data is.
4.HTML is case insensitive while XML is case sensitive.

5.HTML is used for designing a web-page to be rendered on the client side while XML is used basically to transport data between the application and the database.

6.HTML has it own predefined tags while what makes XML flexible is that custom tags can be defined and the tags are invented by the author of the XML document.

7.HTML is not strict if the user does not use the closing tags but XML makes it mandatory for the user the close each tag that has been used.

8.HTML does not preserve white space while XML does.

9.HTML is about displaying data,hence static but XML is about carrying information,hence dynamic.

Thus,it can be said that HTML and XML are not competitors but rather complement to each other
and clearly serving altogether different purposes.

Array vs ArrayList

Array ArrayList
Array comes under the System namespace ArrayList comes under the System.Collections namespace.
Array has fixed size. Arraylists size can be increase and decrease.
Array colletion of similar items ArrayList can hold item of different types of items
Array can be multi-dimensional Arraylist can be single-dimensional only
string[] vowel=new string[]; ArrayList arrlist=new ArrayList();

Difference between Get Method and Post Method

Get Post
Data retrieved using this verb is typically cached by the browser Data retrieved using this verb is not cached by the browser
Data is passed through URL that is Data is appended to URL Post we use to send data through body.
Data sent using this verb is visible in URL. Data sent using this verb is not visible
While sending normal data Get is used. While sending Secured and important data Post is used.
There is limit over amount of data that can be sent using Get depends on browsers. There is no limit over amount of data that can be sent using Post.
This is default method for many browsers. This is not default method and have to be explicitly defined.
Get method can carry only text data Post method can carry text as well as binary data.
Get method is faster as compared to Post Post method is slower as compared to Get

Querystring vs Session

Querystring Session
Querystring is client side state management technique. Session is server side state management technique.
Querystring data is page specific i.e. can be accessed in that page only. Session data can be accessed throughout the session.
Querystring data is visible to user and can be seen in browser url. Session data is not visible to user.
Data is not secured and can be altered hence insensitive data is stored in querystring. Data is secured hence sensitive data such as user information is stored.
Querystring has constraint of Maxlength. Session does not have such constraint.

Abstract class vs Interface
Interface Abstract class
Interface is nothing but contract of the system which can be implemented on accounts. Abstract class is special kind of class that can not be instantiated but can be inherited.
Interface is purely abstract in nature. Abstract is not purely abstract in nature.
Class can inherit multiple interface. Class can inherit only one abstract class.
In interface all methods are without implementation In abstract class some methods are without implementation
Members of interface does not have any access modifier. Members of abstract does have an access modifier
An interface can not contain fields, constructor, destructor. An interface can contain fields, Constructor, destructor.
A class implementing an interface has to implement all the methods of the interface A class implementing an abstract class does not need to implement all the methods of the abstract class
If we add new method to interface then we have to implement that method everywhere where we have implemented interface If we add new method to abstract then we don't have to implement that method everywhere where we have implemented abstract

Thursday, December 13, 2012

CLR Garbage Collection

Load Time—AppDomains
When CLR loads a new application, applications are placed in special memory areas set aside for them called AppDomains. Because CLR provides memory type safety, it is possible for multiple applications to safely cohabit within the same AppDomain. Applications in the same AppDomain function as a group in the sense that they can share data quickly and efficiently, and if the AppDomain is unloaded, all applications and assemblies loaded into that domain are unloaded together.
Run Time—Interoperability
As a .NET application runs, it may make calls into unmanaged code, such as COM components or standard Windows DLLs. Whenever execution of a thread passes between managed code and unmanaged code, a transition is said to occur. These transitions carry certain costs.
One cost of making a transition is that the arguments and return values being passed between the caller and callee must be marshaled. Marshaling is the process of arranging the objects in memory according to the expectations of the code that will process them. Naturally, data types such as strings and complex structures are more expensive to marshal than simple types like integers.
NOTE
In the case of strings, it is often necessary to convert them to different formats such as ANSI and Unicode. This is an example of an expensive marshalling operation.
Another cost of transitioning concerns CLR’s memory manager, known as the garbage collector. (The garbage collector will be discussed in more detail later in the chapter.) Whenever a transition into unmanaged code occurs, CLR must identify all the objects referenced by the call to unmanaged code, to ensure the garbage collector does not move them and thereby disrupt the unmanaged thread. Objects that have been identified as possibly in use by unmanaged code are said to be pinned.
NOTE
Obviously, the most desirable behavior for an application is to minimize the number of transitions needed to do a given amount of work. When testing, use the # of marshalling counter in the .NET CLR Interop performance object to locate areas where application threads are repeatedly transitioning between modes and doing only a small amount of work before transitioning back.
Run Time—Garbage Collection
One of CLR’s most prominent features is automatic memory management, better known as garbage collection. Rather than requiring developers to implement their own memory management, CLR automatically allocates memory for objects when they are created, and periodically checks to see which objects the application is done using. Those objects that are no longer in use are marked as garbage and collected, meaning that the memory they occupy is made available for use by new objects.
Generations and Promotion
Naturally, garbage collection needs to be fast, since time spent managing memory comes at the expense of time spent letting the application do its job.
One assumption about memory management that has withstood considerable scrutiny can be summarized by simply saying that the vast majority of objects are usually needed for only a short amount of time. Microsoft’s garbage collector (GC) makes the most of this by sorting objects into three categories, or generations, numbered 0, 1, and 2. Each generation has a heap size, which refers to the total number of bytes that can be occupied by all objects in that generation. These heap sizes change over the course of an application’s execution, but their initial sizes are usually around 256 KB for generation 0, 2 MB for generation 1, and 10 MB for generation 2.
Objects in generation 0 are youngest. Any time an application creates a new object, the object is placed in generation 0. If there is not enough room on the generation 0 heap to accomodate the new object, then a generation 0 garbage collection occurs. During a collection, every object in the generation is examined to see if it is still in use. Those still in use are said to survive the collection, and are promoted to generation 1. Those no longer in use are de-allocated. You will notice that the generation 0 heap is always empty immediately after it is collected, so there is always room to allocate a new object—that is, unless the system is out of memory, as we discuss below.
NOTE
You may wonder what happens if a new object is so large that its size exceeds the space available on the generation 0 heap all by itself. Objects larger than 20 KB are allocated on a special heap all their own, known as the large object heap. You’ll find performance counters to track the large object heap size in the .NET CLR Memory performance object.
In the course of promoting objects from generation 0 to generation 1, the GC must check to see if there is room to store the promoted objects in generation 1. If there is enough room on the generation 1 heap to accomodate objects promoted from generaton 0 the true GC terminates, having only collected generation 0. If, on the other hand, the capacity of the generation 1 heap will be exceeded by promoting objects into it from generation 0, then generation 1 is collected as well. Just as before, objects that are no longer in use are de-allocated, while all surviving objects are promoted, this time to generation 2. You’ll notice that after generation 1 is collected, its heap is occupied only by those objects newly promoted from generation 0.
Just as generation 1 must sometimes be collected to make room for new objects, so must generation 2. Just as before, unused objects in generation 2 are de-allocated, but the survivors remain in generation 2. Immediately after a collection of generation 2, its heap is occupied by surviving as well as newly promoted objects.
Immediately following a collection, a heap’s contents are re-arranged so as to be adjacent to each other in memory, and the heap is said to be compacted.
Notice that any time generation 1 is collected, so is generation 0, and whenever generation 2 is collected, the GC is said to be making a full pass because all three generations are collected.
As long as only a few objects need to be promoted during a collection, then the garbage collector is operating efficiently, making the most memory available with the least amount of work. To optimize the likelihood that the garbage collector will operate efficiently, it is also self-tuning, adjusting its heap sizes over time according to the rate at which objects are promoted. If too many objects are being promoted from one heap to another, the GC increases the size of the younger heap to reduce the frequency at which it will need to collect that heap. If, on the other hand, objects are almost never promoted out of a heap, this is a sign that the GC can reduce the size of the heap and improve performance by reducing the application’s working set. The exception here is generation 2: since objects are never promoted out of generation 2, the GC’s only choice is to increase the size of the generation 2 heap when it starts getting full. If your application’s generation 2 heap grows too steadily for too long, this is probably a sign that the application should be reviewed for opportunities to reduce the lifetime of objects. When generation 2 can no longer accommodate promoted objects, this means the garbage collector cannot allocate space for new objects, and attempts to create new objects will cause a System.OutOfMemoryException.
The GC also attempts to keep the size of the generation 0 heap within the size of the system’s L2 cache. This keeps memory I/O costs to a minimum during the most frequent collections. When monitoring your application, it may be helpful to see if it allows the GC to take advantage of this optimization.
Pinned Objects
As mentioned earlier, pinned objects are those that have been marked as possibly in use by threads executing unmanaged code. When the GC runs, it must ignore pinned objects. This is because changing an object’s address in memory (when compacting or promoting it) would cause severe problems for the unmanaged thread. Objects therefore survive any collection that occurs while they are pinned.
When monitoring application performance, pinned objects indicate memory that cannot be managed or reclaimed by the garbage collector. Pinned objects are usually found in places where the application is using significant amounts of unmanaged code.
Finalization
Some objects might store references to unmanaged resources such as network sockets or mutexes. Since de-allocating such an object would result in loss of the reference to the unmanaged resource, developers might specify that the GC must cause the object to clean up after itself before it can be de-allocated, in a process called finalization.
Finalization carries several performance costs. For example, objects awaiting finalization cannot be de-allocated by the garbage collector until they are finalized. Moreover, if an object pending finalization references other objects, then those objects are considered to be in use, even if they are otherwise unused. In contrast to the garbage collector, the programmer has no way to directly control the finalization process. Since there are no guarantees as to when finalization will occur, it is possible for large amounts of memory to become tied up at the mercy of the finalization queue.
When a garbage collection occurs, objects pending finalization are promoted instead of collected, and tracked by the Finalization Survivors counter in the .NET CLR Memory performance object. Objects referenced by finalization survivors are also promoted, and tracked by the Promoted Finalization counters in the .NET CLR Memory performance object.
When monitoring an application that uses objects that require finalization, it is important to watch out for excessive use of memory by objects that are pending finalization directly or otherwise.
Differences Between Workstation and Server GC
Whenever a collection occurs, the GC must suspend execution of those threads that access objects whose locations in memory will change as they are promoted or compacted. Choosing the best behavior for the GC depends on the type of application.
Desktop applications that interact directly with individual users tend to allocate fewer memory objects than Web-based applications that serve hundreds or even thousands of users, and so minimizing the latency involved in a garbage collection is a higher priority than optimizing the rate at which memory is reclaimed.
Therefore, Microsoft implements the GC in two different modes. Note that the best GC is not chosen automatically - CLR will use the Workstation GC (mscorwks.dll) unless the developer specifies that the application requires the Server GC (mscorsvr.dll) instead.
NOTE
In our experience, with most Web application scenarios, we have found that the Server GC out performs the Workstation GC.

ASP.NET Web.Config

Use of Web.Config File.
How many ways you can use it.

Web.Config is xml based text file.It is derived from Machine.config file. It means whatever defined/written in Machine.Config file will be overwritten by Web.Config file.

Same way you can have multiple Web.Config files in same ASP.Net Wep Project. According to folder structure what ever written in parent folder will be overwritten by child folder Web.Config file.  

Grate functionality of Web.config file is it does not required iis-restart or application restart. Next request will use updated web.config file. In traditional ASP project developers need to restart iis. 

Example : You can have multiple configuration file in one web application in different folders to give different kind of authorization to different users.     
Consider a scernario you have one website, inside that you have 5 resourses(usually aspx pages) as below

1. welcome .aspx
2.usermanagement.aspx
3.home.aspx
4.courses.aspx
5.facultyDetails.aspx

in this case you would like to give the access of
usermanagement.aspx to only admin users
courses.aspx,facultyDetails.aspx to only registerd users
welcome .aspx,home.aspx to all users

so inorder to acheive this ,what we will do is

we will create 2 folders like
1.Admin
2.RegisteredUSer

then we need to place usermanagement.aspx in admin folder as add a web.config in this folder and in that file we can authorize the only admin users.
We need place courses.aspx,facultyDetails.aspx in Registered User folder as add a web.config in this folder and in that file we can authorize the only registered users.

rest of the pages we can place in root folder itself.


The web.config file contains information that controls

Ø  module loading,
Ø  security configuration,
Ø  application language,

Ø  compilation settings,


<system.web
          <compilation     debug="true" strict="true" explicit="true" batch="true"                  optimizeCompilations="true" batchTimeout="900" maxBatchSize="1000" maxBatchGeneratedFileSize="1000" numRecompilesBeforeAppRestart="15" defaultLanguage="c#" targetFramework="4.0" assemblyPostProcessorType=""
> 
<assemblies>
<add assembly="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>    
</assemblies>
</compilation>
</system.web>

Ø  Web.config files can also contain application specific items such as database connection strings.

Ø  Error redirect

i.e.

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
<configuration/>

<system.web>
     <customErrors defaultRedirect="GenericError.htm" mode="RemoteOnly">
        <error statusCode="500" redirect="InternalError.htm"/>
     </customErrors>
</system.web>
 

Ø  Page Level Settings

i.e.

<system.web>
   <pages enableViewStateMac="true" enableEventValidation="true" viewStateEncryptionMode="Always">
<system.web>

Or

<system.web>
               <pages buffer ="true" styleSheetTheme="" theme ="Acqua”
                       masterPageFile ="MasterPage.master"
                                              enableEventValidation="true">
<system.web>

Ø  Location Sections

i.e.

<location path="Login.aspx">
   <system.web>
           <authorization>
            <allow users="*"/>
           </authorization>
   </system.web>
</location>

<location path ="Uploads">
    <system.web>
           <compilation debug = "false"/>
    </system.web>
</location>

Ø  Add Namespace and control to application

i.e.

<system.web>
  <namespaces>
           <clear />
           <add namespace="System" />
           <add namespace="System.Collections" />
           <add namespace="System.Collections.Generic" />
           <add namespace="System.Collections.Specialized" />
           <add namespace="System.Configuration" />
           <add namespace="System.Text" />
           <add namespace="System.Text.RegularExpressions" />
           <add namespace="System.Web" />
           <add namespace="System.Web.Caching" />
         </namespaces>
         <controls>
           <add src ="~/controls/maleBed.ascx" tagPrefix ="mycontrol" tagName ="male"/>
           <add src ="~/controls/femaleBed.ascx" tagPrefix ="mycontrol" tagName ="female"/>
         </controls>
       </pages>
   </system.web>

Ø  Session State and View State Settings
<Pages EnableViewState="false" />
<sessionState mode="InProc" />
<sessionState mode="StateServer“ stateConnectionString= “tcpip=Yourservername:42424" />
<sessionState mode="SQLServer" sqlConnectionString="cnn" />
Ø  HttpHandler Settings
<httpHandlers>
         <add verb="*" path="*.jpg" type="ImageHandler/>
         <add verb="*" path="*.gif" type="ImageHandler/>
</httpHandlers>

Ø  HttpModule Settings

<httpModules>

      <add type ="TwCustomHandler.ImageHandler" name ="TwCustomHandler"/>

      <remove name ="TwCustomHandler"/>

      <clear />

</httpModules>

 

Ø  Authentication, Authorization, Membership Provider, Role Provider and Profile Provider Settings

Authentication Settings

 

<authentication mode="Forms">

     <forms cookieless="UseCookies" defaultUrl="HomePage.aspx"

                    loginUrl="UnAuthorized.aspx" protection="All" timeout="30">

      </forms>

</authentication>

 

Authorization Settings

          <authorization

                    <allow roles ="Admin"/>

                    <deny users ="*"/>

      </authorization> 

 

Membership Provider Settings

<membership defaultProvider="Demo_MemberShipProvider">

      <providers>

         <add name="Demo_MemberShipProvider"

              type="System.Web.Security.SqlMembershipProvider"

              connectionStringName="cnn"

              enablePasswordRetrieval="false"

              enablePasswordReset="true"

              requiresQuestionAndAnswer="true"

              applicationName="/"

              requiresUniqueEmail="false"

              passwordFormat="Hashed"

              maxInvalidPasswordAttempts="5"

              minRequiredPasswordLength="5"

              minRequiredNonalphanumericCharacters="0"

              passwordAttemptWindow="10"

                             passwordStrengthRegularExpression="">

      </providers>

</membership>

 

Role Provider Settings

<roleManager enabled="true" cacheRolesInCookie="true"

cookieName="TBHROLES" defaultProvider="Demo_RoleProvider">

     <providers>

          <add connectionStringName="dld_connectionstring"

             applicationName="/" name="Demo_RoleProvider"

             type="System.Web.Security.SqlRoleProvider, System.Web,

             Version=2.0.0.0, Culture=neutral, ublicKeyToken=b03f5f7f11d50a3a"/>

     </providers>

</roleManager>

Ø  Config Sections : ConfigSections helps you to create your own custom configuration section that can be used with the web.config file.

<configSections>

    <sectionGroup name="pageAppearanceGroup">

      <section

        name="pageAppearance"

        type="PageAppearanceSection"

        allowLocation="true"

        allowDefinition="Everywhere"

      />

 </sectionGroup>

 </configSections>

 

Ø  Reading configuration section values

// Intialize System.Configuration object.

Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");

 

//Get the required section of the web.config file by using configuration object.

CompilationSection compilation = (CompilationSection)config.GetSection("system.web/compilation");

 

//Access the properties of the web.config

Response.Write("Debug:"+compilation.Debug+"<br/>""+"Language:"+compilation.DefaultLanguage);

Ø  Update the configuration section values

Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");
//Get the required section of the web.config file by using configuration object.
CompilationSection compilation = 
            (CompilationSection)config.GetSection("system.web/compilation");
//Update the new values.
compilation.Debug = true;
//save the changes by using Save() method of configuration object.
if (!compilation.SectionInformation.IsLocked)
{
    config.Save();
    Response.Write("New Compilation Debug"+compilation.Debug);
}
else
{
    Response.Write("Could not save configuration.");
}

Ø  Encrypt Configuration Sections of Web.config File

Configuration config = WebConfigurationManager.OpenWebConfiguration

                             (Request.ApplicationPath);

ConfigurationSection appSettings = config.GetSection("appSettings");

if (appSettings.SectionInformation.IsProtected)

{

    appSettings.SectionInformation.UnprotectSection();

}

else

{

    appSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");

}

config.Save();