Structure of my ASP.NET Web Applications

I’ve had some requests recently to describe how I structure my ASP.NET web applications.  To be clear, this is not the only way to structure your application.  It is MY way.  It works for me and it works for all of my clients.  If you don’t already have something that’s working for you, it will probably work well for you as well.

 

ASPX and ASCX files

First, let’s assume that our site is rather flat.  That is, all of our ASPX files are at the root of the application.  Not that this is always true, but it will allow us to cover the general cases first.  Toward the end of this post, I’ll describe how I handle sites with subdirectories in them.

All of my web user controls go in a /controls directory.

Site Images

As a general rule, I put all of my site specific images in /images.  These are images that the application will use to display page-specific information and should not be confused with images we will use for general site look and feel.

JavaScript files

All of my JavaScript files go in a /js directory by convention.  If the files have something to do with an ASPX file, I’ll name it the same as the ASPX file.  If it is specifically tied to a web user control, I’ll put it in a /js/controls directory with the same name as the control.  Any JavaScript that happens to be common to multiple pages of my site, I’ll place in a /js/common directory.  This includes JavaScript that is associated with the master page of the site.

Theme Structure

The structure of my individual theme directories is similar.  All the CSS files go in the base directory, images in the theme’s images directory.  If I have CSS that is specific to a particular page, I’ll create a separate CSS file and give it the same name as the page it controls.

Sites with Subdirectories

With larger sites, it is sometimes valuable to put your ASPX files in subdirectories to keep things even more organized.  If I do that, then I create corresponding subdirectories in my JavaScript, controls, and images directories as it makes sense.

Related Post

One Response to “Structure of my ASP.NET Web Applications”

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail

Bear