MenuBar

Wednesday 16 July 2014

ASP.NET Application folder (also called special folder) for maintaining security, accessibility, durability and robustness in ASP.NET Websites

In a general website there are collection of files, resources posted on website’s root folder that used by web pages globally on the same website like .aspx files, .jpg file, .txt files, .js scipt files, .css files etc. these resources need to placed in same website folder so it can be used by Web Pages.

Sometimes it can be vulnerable to keep these resources in website folder because of internet junkies that always keep their eyes on vulnerable sites to hack those resources.
Thanks to ASP.NET , it provide application folder to place resources, files In a standard manner that maintain by .NET run-time.

ASP.NET 3.5 supports eight types of special folders and each folder has their own advantage. I will explain these eight in details.

  1. App_Browsers
  2. Bin
  3. App_Code
  4. App_Data
  5. App_GlobalResources
  6. App_LocalResources
  7. App_WebReferences
  8. App_Themes

By default these special folder are not available in your empty website , but you can add easily when you need in few steps

Steps :
  1. Create a website in visual studio by clicking on Menu  file à New website .
  2. On solution explorer right click on root folder à Add Asp.Net Folder àchoose from Eight ASP.NET folder you want



In a website you can add each of these folders only once. The folder that you will add once will remove from add option automatically.
These folder maintains access security. No one can access files of these folder directly through the url, if someone really does so server gives forbidden  message. 

Let’s dig into these special folders

App_Code Folder :

In App_Code Folder we can place class files like .cs or .vb , text and xml files. It will compiled automatically and can be access throughout the web application, means we can access directly on all the pages that is created on current website. In three layered architecture App_Code plays very important role.  To add App_Code folder àOn solution explorer right click on root folder à Add Asp.Net Folder àApp_Code  and its done.
After that to add new or existing files on App_Code right click on App_Code folder à Add New Item à choose file  its done.



App_Browsers :

App_Browsers is used to access browser information and capabilities.This folder contains browser information files like .browser.
Bin Folder:
In this folder we can placed executable files or assembly  files that can be reference throughout the web application .



App_Data Folder :

We can place database files in this folder like .mbf, .mdb,Xml etc. by doing this database file can be accessed anywhere in our web application. We can add .mbf, .mdb,Xml files to the App_Data folder directly by selecting Add New Item.

App_GlobalResources :

We can store resources that we need to access in any page or any code. ASP.NET uses resource files to make supporting multiple languages simpler. We can store single resource file that need to use in multiple pages globally. You can add a global resource file by right clicking on the App_GlobalResource  folder and clicking on Add Items.

App_LocalResources :

The App_LocalResource  folder contain local resource files . we can place  resources file on subfolder of website , in App_LocalResources we can store resources that need to be used by local webpage. There can be multiple App_LocalResources folder in a website but in subfolder that locally access it.You might have local resources for every page in your website, you might have App_LocalResource subfolders in every folder.

App_WebReferences :

App_WebReference  folder contain references to any web services. We can easily add new web reference to our web application by right clicking on App_WebReference  folder à add web reference.

App_Themes :

We can store page styling files like .css, .skin file to this folder. We can create theme style for our web page. When we add an App_Theme folder, a subfolder with name Theme1 will be automatically created.  We can rename it and then add .css to it. These styles can be applied to ASP.NET control directly. We can as many themes as we want but folder name should be unique. 

No comments:

Post a Comment