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.

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • ASP.NET Internationalization – ThemesASP.NET Internationalization – Themes A couple of weeks ago I started a series on ASP.NET Internationalization where we started by covering the basics, that is, using RESX files to supply language-specific strings in our […]
  • Access a control by ID From Within a Databound ControlAccess a control by ID From Within a Databound Control Databound controls are at once very easy and very frustrating.  If you just need to do some simple databinding that gets a list of items on the screen and you need the ability to […]
  • iTextSharp – Adding ImagesiTextSharp – Adding Images Last week I showed how to use form fields to control placement of dynamic data. But what if you want to dynamically place images in your PDF?  You can stuff them into a form field […]
  • DotNetNuke Modules – DNN Controls – LabelDotNetNuke Modules – DNN Controls – Label The DotNetNuke framework has several built-in controls that you should use instead of the controls you would typically use in an ASP.NET application. Before we can go much further, we need […]
  • ASP.NET Cross Domain Form SubmissionASP.NET Cross Domain Form Submission Not to be confused with cross page posting, cross domain submission allows us to post the contents of an ASP.NET form to a completely different domain. To achieve this we will need to […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.

One Pingback/Trackback