Enterprise Library In ASP.NET

In this article I am going to explain Enterprise Library. It is a collection of application blocks and core infrastructure. Enterprise library is the reusable software component designed for assisting the software developers.

We use the Enterprise Library when we want to build application blocks intended for the use of developers who create complex enterprise level application.

Enterprise Library Application Blocks

  1. Security Application Block

    Security Application Block provide developers to incorporate security functionality in the application. This application can use various blocks such as authenticating and authorizing users against the database.

  2. Exception Handling Application Block

    This block provides the developers to create consistency for processing the error that occur throughout the layers of Enterprise Application.

  3. Cryptography Application Block

    Cryptography application blocks provides developers to add encryption and hashing functionality in the applications.

  4. Caching Application Block

    Caching Application Block allows developers to incorporate local cache in the applications.

For using the Enterprise library in project we need to follow the below given steps:

Step 1: Start Visual Studio.



Step 2: Now for creating a website, click on the file, go to new and click on the Project.


Step 3: Now we need to right click on the website and click on Manage NuGet Packages.


Step 4:Now in next step we need to just type enterprise library in search box.


Step 5: After typing enterprise library we need to click on Install on Enterprise Library Data Access Application and install the packages.


After Installation we can check that Bin folder automatically created in the solution explorer and it contains the two dll.



Now for using the Enterprise Library we need to add the following two namespaces.

  1. using Microsoft.Practices.EnterpriseLibrary.Data;  
  2. using Microsoft.Practices.EnterpriseLibrary.Data.Sql;  

After adding these namespaces we can use the enterprise library in our application.

  1. public Result InsertDetail(UserRegistration rg)  
  2.        {  
  3.            Result result = new Result();  
  4.            objDB = new SqlDatabase(getconnection);  
  5.            using (DbCommand objcmd = objDB.GetStoredProcCommand("registrationMCN_Prdr2"))  
  6.            {  
  7.                objDB.AddInParameter(objcmd, "@UserName", DbType.String, rg.UserName);  
  8.                objDB.AddInParameter(objcmd, "@Pass", DbType.String, rg.pass);  
  9.                objDB.AddInParameter(objcmd, "@Email", DbType.String, rg.Email);  
  10.                objDB.AddInParameter(objcmd, "@Phone", DbType.String, rg.Phone);  
  11.                objDB.AddInParameter(objcmd, "@States", DbType.String, rg.States);  
  12.                objDB.AddInParameter(objcmd, "@City", DbType.String, rg.City);  
  13.                objDB.AddOutParameter(objcmd, "@Status", DbType.Int16, 0);  
  14.            //    bool isemail = checkEmailExist(rg.Email);  
  15.                try  
  16.                {  
  17.                    objDB.ExecuteNonQuery(objcmd);  
  18.                    result.Status = Convert.ToInt32(objDB.GetParameterValue(objcmd, "@Status"));  
  19.   
  20.                }  
  21.                catch (Exception)  
  22.                {  
  23.                    throw;  
  24.                }  
  25.                return result;  
  26.   
  27.            }  
  28.        }  

In this article we will learn how to use enterprise library in our application. Hope it will be helpful for beginners when they want to use this library in their application.


Similar Articles