Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.


YOU ARE HERE: HOME Articles Overview ASP NET Application Folders About Special folders in ASP NET

Overview ASP.NET Application Folders (About Special folders in ASP.NET)

View(s): 6604

Beginner's Guide to ASP.NET Application Folder


This Article Describe you about Special folders in ASP.NET like App_Code, App_Theme, App_Data, etc..

ASP.Net 2.0 uses file-based approach. It's means all class files, resource files, Data, Folder are maintain in a hierarchical way. If we are working with ASP.Net 2.0, we can add files and folder from "Add Items" Options. If we look at a sample application hierarchy, it will looks following figure.

Description: Description: Description: beginn1.jpg

we can add as many as files and folder (as per our requirements ) with our solutions.  And it's doesn't need to recompile them each and every time when they are added. Its Asp .NET’s overhead to dynamically compiled them when required. So, what ASP.Net 2.0 does, it contain a defined folder structure, contains files (Classes, Images, Resources etc..), compile them dynamically and even we can access those files throughout the application. ASP.Net Provides some special folder also to maintain files and resources. Let's see the advantages of using those folder .

Advantages of ASP.NET Application Folder 

Following are the main advantages of use of ASP.Net Application Folder

  • We can maintain resources (Classes, Images, Code, DatabasesThemes) in a organized way, which give us to developed and maintain sites easily.
  • All files and folder are accessible by through the application.
  • We can add as many files as possible as per our requirements.
  • Files are compiles dynamically when required.

Different Types of Application Folders 

Asp.Net treats following Folder in a special way, those are

  • App_Code
  • Bin
  • App_Data
  • App_Theme
  • App_Browser
  • App_WebReference
  • App_LocalResource
  • App_GlobalResource 

Details of Application Folder

Now, look at the use of those folder , I am starting from App_Code.

App_Code Folder :  

As name suggests, App_Code Folder store classes, typed data set etc. All the items that are store in App_code, are automatically accessible by throughout the application. If we store any class files (like .cs or .vb ) its compile them automatically. It’s automatically create type data set from .Xsd file and create XML Web services proxy class from WSDL.  Let's have a look how we can use App_Code Folder.

We can add App_Code Folder, by  Solution File -> Right Click -> Add Asp.Net Folder -> App_Code. Now App_Code Folder is now added with your application.

Description: Description: Description: beginn2.jpg


Note :- Try to Add one more App_Code Folder by using following steps. Opppps... No , App_Code folder is not available there. So , Asp.Net allows to add App_Code folder for once.

Now we can add new items like Class, text, xml files inside the App_Code folder or we can also add existing files.

Description: Description: Description: beginn3.jpg

Let's have a look one example , that how its works . In the App_Code folder , I have added a class "MyCSharpClass.cs" .

Description: Description: Description: beginn4.jpg

In that class I have written small spice of code for adding two number.

Description: Description: Description: beginn5.jpg

Now, Try to access this class, from any where of you application. "MyCsharpClass" will be accessible  through out the application.

Description: Description: Description: beginn6.gif

 If we want to store different class like .cs, .vb then what will happened. If we kept both .cs and .vb class it will give following compilation error.

Description: Description: Description: beginn7.jpg

Because, All the classes contained in App_Code Folder are built into a single Assembly , It can't have different language in root level or even a child level folder in following way.

Description: Description: Description: beginn8.jpg

 We have a solution to overcome this problems. We have to create separate folder for C# and VB or other classes.

Description: Description: Description: beginn10.jpg

 Store class files separately on those folder and an configure the folder hierarchy on web.config file .

Description: Description: Description: beginn9.jpg

Now , I am moving to our next Part that is Bin Folder ..

Bin Folder:

Bin folder is used for keeping the assemblies inside it. we can access those as a reference from anywhere of our web application. Use of Bin folder comes to the picture if we use any class library with our web application. Suppose, we are creating a Class Library  "TestLib" , After build the library , we will get "TestLib.dll", Now Right Click on Solution file -> Add References -> Project , Select TestLib Project, Click on OK. Check the bin folder, its contain TestLib.Dll and TestLib.Pdb files.

Description: Description: Description: beginn11.jpg

Assemblies in Bin folder do not need to registered . recognize the presence of dll inside the Bin Folder . Keeping .pdb files inside bin folder helps us for debugging. Main limitation of storing assemblies in bin folder that , they are in scoped of Current Application . Therefore they cannot access any code outside of current web application. [Source]

Let's have a look on App_Data Folder

App_Data Folder :

App_Data Folder used as a "data storage" for the web application. It can store, .mdf, .mdb, XML, etc  files.  Its manage all of your application data in a centrally manner. It can be accessible from anywhere of your web application.  The real advantage is that any file you place in App_Data won't be downloadable.

We can add .mdf file into App_Data Folder , directly by "Add New Item" . From there we can create table, procedure, function without opening SQL Server.  Now if we want to add that data in our application we can easily use.

Description: Description: Description: beginn12.jpg

Now, look at the connection string that we need to write for accessing App_Data folder databases.

Description: Description: Description: beginn13.gif

So we can connect with "MyDB.mdf" file using this ConnectionString . Check the bellow example which I have used to read the Table data from "MyDB.Mdf" file.

Description: Description: Description: beginn14.gif


App_Theme Folder : 

If you want to give your web sites a consistent looks then you need to design Themes for your web application. App_Themes folder contains your Themes . A Theme folder can contain two Folder, one for Css files and another for Skin files. When we will add "App_Theme" automatically a sub folder with name "Theme1" will be created. we can change the name of Theme folder as per our requirement.

Description: Description: Description: beginn15.jpg

I will not cover how to create skin file or Css file in this article, my main concern is how to apply them. You can find the details of  Skin and Css overhere .

Now we have to apply the theme  to the page, there are several way to do that, we can set the theme from "aspx" page at page directive in following way,

Description: Description: Description: beginn16.jpg

While we are going to set theme  from aspx page list of Theme available to us as shown in picture. We can set the theme from code behind file also and even we can change theme runtime (using HttpHandler).

App_Browser Folder :

App_Browser Folder contain browser information files (.browser files). These files are xml based files which are used to identify the browser and browser capabilities . you will find the browser files in following location,

Description: Description: Description: beginn17.jpg

If you want to change .browse file, just copy the file to App_Browser Directory and change it. You can create new Browser files by just click on "Add New Item " on App_Browser Folder

Description: Description: Description: beginn18.jpg

As I already mention, Browser file is an configuration file, generally its look like this

Description: Description: Description: beginn19.gif

For More information

App_WebReference :

AS name suggest, App_WebReference folder contain reference of any web services. If we added any web servies with our web application it will come automatically inside App_WebReference folder as in windows application if we added any ".dll" its comes under "Reference" Folder .

Description: Description: Description: beginn20.jpg

ASP.Net Resources :

                  Before start about App_GlobalResource and App_LocalResoce, I would like to give small introduction of Resource. If you are creating a sites for multinational company or a public web sites that can be accessible by all over the world,  you need to consider the best ways to address users in different cultures with different languages with different country.ASP.NET provides the infrastructure to create Web applications that automatically adjust formatting and languages according to user preferences using Resource files.  Main purpose of Resource files is "Localization" of web application.

                ASP.NET uses resource files to make supporting multiple languages in a simpler way. Visual Studio 2005 can automatically generate XML resource files that contain text for your controls in different languages. When user visit the sites they can change the languages of the sites based on there preference. There are two type of resource

  • Local Resource
  • Global Resource

App_LocalResource folder contain Local Resources files and App_GlobalResource Folder contain  Global Resources files.

App_LocalResources :

Local Resource :-  Local resources are specific to a single Web page and should be used for providing multilingual functionality  on a Web page.

               Local resources must be stored in an App_LocalResources subfolder of the folder containing the Web page. Because you might have local resources for every page in your Web application, you might have App_LocalResources subfolders in every folder.

Resource file name should be like <pageName>[.langauge].resx . some example of local resource files are, Mypage.aspx.ex.resx,   Default.aspx.resx is the base resource file to use if no other resource file does not match with user current culture.

if you want to create local resource for a page , open the design view of the page and then from "Tool Menu" -> "Generate Local Resource" . The you will see a resource file is automatically created on App_LocalResource Folder. 

Description: Description: Description: beginn21.jpg

Following code showing you XML Code for the resource file. for changing Resource file we can change from xml  or Resource Editor also.

Description: Description: Description: beginn22.gif

 If we changing any thing on the page  resource file will automatically updated. If want to test application for Local_Resource, Just create a copy of "Default2.aspx.resx" and renamed it to " ( for french ). Now for a test, I have changed the button tool tip  for French Resource to "French ToolTip". Now Change your IE setting and set "French as default Culture" from Tools -> Internet options -> Languages , Add French in the list and test the Application.

Description: Description: Description: beginn23.jpg

 Test the Button Tool Tip and you can test it for other Language also. 

Description: Description: Description: beginn24.jpg


App_GlobalResources :

Global resources can be read from any page or code that is in the Web site . Global resources must be stored in the App_GlobalResourcesfolder at the root of the application. We should use App_GlobalResource folder when we need single resource from multiple web pages. we can  define control properties by manually associating them with resources in global resource files.  you can add global resource file by right click on "App_GlobalResources" folder and click on "Add Items". Add .resx files as resource.

Description: Description: Description: beginn25.jpg

We can access those resources by programmatically .by Resource.Resource Object.

e.g :

Label1.Text= Resource.Resource.MyText

We can use the GetLocalResourceObject and GetGlobalResourceObject methods to access global resources, and then cast them to the correct type .

Label1.Text = GetLocalResourceObject("Label1.Text").ToString();

  Last updated on Sunday, 25 August 2013
  Author: Mr. Ponna
4/5 stars (6 vote(s))

Register Login Ask Us Write to Us Help