Skip to main content

How to Hide web application code from users in ASP.NET

If we talk about web application projects then we simply says that each presentation page attach with code behind page(where you can design your business logic code). If you are a developer and you want to sell your project without code then you will hide its business logic code behind the ".DLL" (dynamic link library) file.
There are available some steps to do this task.
These are
  1. Create a web application project (file--new project--Visual C# --Web -- ASP.NET web Form application)
  2. Write project name, which you want, In this article we take "hide code" as a project name.
new web project in

3. Delete all directories from the solution explorer. Because i want to design only business logic code, after coding we will create DLL file for this. For this you should attach a class file in this project. Take a look after deleted all files from solution explorer.

deleted all files from solution explorer.

4.  Now, we learn how to attach a class file in the project. Select "add new item" from context menu by right clicking on project name.
Select "add new item"

Now, here appear a new window. In this window select code in left panel and also select class in the right panel.
 select code in left panel and also select class in the right panel.

5.  Write the business logic code for display message on the screen, so we raise a button handler code in displayResult class.
You can design your code for multiple classes through this approach we will create a business logic model. Suppose i want to create a small application for employee, in which i want to display data of employee also display employee salary. Application hold two function first for employee data and second for employee salary. Similarly through this code i want to display "Hello World!" message on the browser. Now your code look like
business logic model

In the above mentioned snap displayResult class inherits from page class, page class contains some object like response,request etc. if you want to use page objects then created class must be inherits from Page class. Also mentioned two namespace, first is System.Web.UI and other is System.Web.UI.WebControls.
6.  Build the solution by selecting "Build HideCode" from Build Tab.
Build the solution by selecting "Build HideCode"

Now your .DLL file has made in Bin folder of the project. File contains single namespace(HideCode) , class(displayResult) and single method(displayresult( )).
7. Now add new project in the solution by right clicking on solution name. Select ASP.NET Web form application project in appeared window also write name of the project, i keep presentation part as a project name. Now your solution explorer contains two project, see below
solution explorer contains two project

8.  Now add new web form in the project also change the name of it, i keep  "presentationpage.aspx" as a project name. This page is basically used for designing purpose. Through this page we can call method of other projects, but will do some changes in the page . Before doing this, first of all add above mentioned project reference in the current project. Learn how to add reference in the project.
Note : Remove all attached file from this page.
 Remove all attached file from this page

(a) Add Reference by right click on References link. select Solution from the appeared window also select .dll checkbox which is appeared in right panel of it.
select .dll checkbox which is appeared in right panel

9. Remove "CodeBehind" attribute from presentation page also add inherits attribute in the page directive. Assign namespace , which is created in earlier project  with class name. Look like
 Remove "CodeBehind" attribute

10. Add button in the page also raise onclick event on it. Call displayresult( ) method, which is created in business logic code. now your code look like
<%@ Page Language="C#" AutoEventWireup="true" Inherits="HideCode.displayResult" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="hide coding" OnClick ="displayresult" />

Now your code generate the following output

How to Hide web application code from users in ASP.NET

First code of line define the page directive. In this line,you must to add namespace with class name in inherits attribute. After that you can access methods and properties of that class. In this code i also access method of displayResult class using Button click event.


Popular posts from this blog

difference between structure and union in C Language

In c language article we will see the difference between union and structure. Both are the user define datatype in c language. See the table which is mentioned below: ASP.NET Video Tutorial Series Structure Union1.The keywordstruct is used to define a structure 1. The keyword union is used to define a union. 2. When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater than or equal to the sum ofsizes of its members. The smaller members may end with unused slack bytes. 2. When a variable is associated with a union, thecompiler allocates thememory by considering the size of the largest memory. So, size of union is equal to the size of largest member. 3. Each member within a structure is assigned unique storage area of location. 3. Memory allocated is shared by individual members of union. 4. The address of each member will be in ascending order This indicates that memory for each member will start at different offset v…

Difference between Linear search and Binary Search in c language

SQL Video Channel : Download all SQL Video

Binary Search Linear Search Works only on sorted items. such as  1,2,3,4,5,6  etc
Works on sorted as well as unsorted items. 12,4,5,3,2,1 etc Very efficient if the items are sorted Very efficient if the items are less and present in the beginning of the list. such as Suppose your list items are : 12,3,4,5,1 and you want to search 12 number then you get beginning in the list. Works well with arrays and not on linked lists. Works with arrays and linked lists.
Number of comparisons are less More number of comparisons are required if the items are present in the later part of the array or its elements are more.

Memory representation of Linked List Data Structures in C Language

Memory representation of Linked List

             In memory the linked list is stored in scattered cells (locations).The memory for each node is allocated dynamically means as and when required. So the Linked List can increase as per the user wish and the size is not fixed, it can vary.

               Suppose first node of linked list is allocated with an address 1008. Its graphical representation looks like the figure shown below:

      Suppose next node is allocated at an address 506, so the list becomes,

  Suppose next node is allocated with an address with an address 10,s the list become,

The other way to represent the linked list is as shown below:

 In the above representation the data stored in the linked list is “INDIA”, the information part of each node contains one character. The external pointer root points to first node’s address 1005. The link part of the node containing information I contains 1007, the address of next node. The last node …