This article has a comprehensive listing of file types that you are likely to encounter in a web site developed with Visual Studio/ASP.NET. These files are categorized into:
- Common ASP.NET File Types
- Less Common ASP.NET File Types
- Non-ASP.NET File Types
The example files given below allude to the situations you might see them in.
Common ASP.NET File Types
Files that Contain UI
The ubiquitous .aspx
This is the most important extension you see in the ASP.NET development. It represents a single page (or a web form page). The very first line you see in this file is the Page directive: <%@ Page …… %>. This directive also has the properties of this particular page.
Examples: default.aspx, login.aspx.
Common UI with .master
This is the extension for master pages. The master pages make it extremely easy to provide common elements like headers, menus, and footers to all the pages, without having to code them separately for each page. At the top of this file, you will find the Master directive: <%@ Master …… %>. The regular pages (.aspx) can be made to inherit the entire content of master pages.
Examples: masterpage.master, support.master.
Post-development flashy UI with .skin
Themes are a new feature in ASP.NET 2.0. The .skin files contain the code to enable the themes. While themes might not be used extensively on smaller sites, they will be widely used on serious web sites.
Files that Contain Code
Code behind the web pages with .aspx.cs or .aspx.vb, etc.
These are the code files for a given page. They used to be called code-behind files, but now the ‘behind’ is dropped. The final extension in the name depends on the language you use for the code; i.e. .cs for C#, .vb for VB.Net, and so on. You will see a partial class in this file (this class name is set in the Page directive). This file, ideally, should hold only the event handler code (like Page_Load, Button_Click, etc.) and all the generic code should be in class files that go into the App_Code directory.
Examples: default.aspx.cs, login.aspx.vb.
Code for the common UI with .master.cs or .master.vb, etc.
These are the code files for master pages, just like aspx.cs, etc. are code files for individual pages. You will find a class filled with event handlers for the given master page.
Examples: flowers.master.cs, hr.master.vb.
UI-less code with .cs, .vb, etc.
Not all the code goes into the code files for web form pages or master pages. All the generic classes (like utility classes or data access classes) will go into .cs (for C#) and .vb (VB.Net) files. In the previous versions (before C# 2.0), a C# class could not span multiple code files; but with partial classes in latest versions of C#, we can use as many files as are convenient to place a class. If a class becomes that large, you should think of splitting it along the lines of logical separation and creating multiple classes.
Examples: customer.cs, product.cs.
Setting up the site with .config
Typically, you will have one web.config file for the web site (you can have one in each directory). This file can contain a whole bunch of configuration settings; and most likely you will find the database connection strings (membership database, application database, etc.). In the older versions, you had to edit this file by hand (which wasn’t all that bad), but now you can edit this file by setting various parameters in the Web Site Administration Tool
Examples: web.config, app.config, machine.config.
Less Common ASP.NET File Types
Following are slightly less common types of ASP.NET files you will encounter during the development of a web site.
Custom Controls in .ascx files
Contains code for user controls. Before long, you will see that certain UI (HTML) is being used over and over again in various pages. You can place that block of UI code in an .ascx file and reuse it with single call. Before the advent of Master Pages, this was the way the common elements like headers, footers, menus, etc. were displayed consistently in several pages.
Web Services in .asmx files
Contains the web service classes and methods. Web services are collections of methods without UI, and can be called from other websites programmatically. In this case, typically, you will create web service projects that primarily contain an .asmx file.
HTTP Handlers in .ashx files
Contains the code for custom HTTP handlers. How does IIS (the webserver) know what to do with the requests for files with .aspx extension? We tell IIS via the Application Configuration box that when there is a request for an .aspx file, send that to aspnet_isapi.dll, which would then generate the appropriate HTML and send that back to webserver. That’s why you see all the ASP.NET extensions are set to call aspnet_isapi.dll as shown in Figure 1.
Figure 1. ASP.net extensions are handled by the aspnet_isapi.dll
Now, let’s say you have a file type called .abc and you want to send a certain HTML whenever user requests for one those files. First you would associate .abc with aspnet_isapi.dll, which brings the request into ASP.NET. But then, ASP.NET doesn’t know what to do with it. For this you write an HTTP handler (which resides in the file .ashx) and via the config file you associate the extension (e.g. .abc) to the handler.
Global Events in .asax files
You write the event handling code for pages and the master pages in the code files (.cs, .vb, etc.). But where would you handle the global application events like Application Start? You have a class in the file Global.asax.
TOC for the entire site via .sitemap files
Creating and maintaining an accurate and attractive site map is a challenging task, especially, for large sites. In Visual Studio, .sitemap file is used store the sitemap nodes and create the appropriate hierarchy among these nodes. Then you can use controls like TreeView to display these nodes (individual pages) in a nice creative fashion.
Support for multiple browsers with .browser files
Unless you are developing a site that is to work perfectly on both regular (PC-based) browsers and mobile browsers, you are not likely to see these files. The .browser files contain logic for displaying different pages for different types of browsers.
Non-ASP.NET File Types
Now let’s look at some file types that are not specific to ASP.NET development but, you see a lot of them in the Visual Studio projects.
What is a web site without images? You will probably see lots of files with .gif and .jpg extensions, among others.
The raw .htm, .html
While all the ASP.NET code in your web site is geared towards ultimately generating HTML files, you probably won’t create a whole lot of HTML files from within Visual Studio. However, you might find yourselves using a lot of .htm/.html files from the existing sources.
Styling with .css
The stylesheet code is used stored in these files. It would be hard to enforce consistent styling across various user interface elements without one or more .css files.
The world of XML with .xml, .xslt, .xsd
You will find yourselves using .xml files for generated or made up data. You would develop .xslt files to transform one type of xml file into another type. For defining the structure of an xml file, you would use the XML Schema Definition files stored in .xsd files.
Most acceptable scripting with .js
Databases with .mdf, .ldf
If you use SQL Server as your database engine, then you will find one or more .mdf files for storing the data and .ldf files for storing the log information.