 |
 |
Recent
Articles |
Refactoring Your ASP.NET Project One day at work i was refactoring my code as I do everyday, when it suddenly hit me that our ASP.NET projects were also refactored in a sense. For those of you who don't know what refactoring is, here's...
ASP.NET: Permanent Redirection The easiest way to make a redirection in ASP.NET is using Response.Redirect(url). What it actually does is, that it creates a response with the "302 (Object Moved)" status code and the target destination.
Validating a URL with Regular Expressions I had to build web form that took user input from standard ASP.NET input controls. In one of the text boxes the user must enter a valid URL, so I had to make some validation logic.
Visual Studio 2005 - Publishing Web Site What's the purpose of site precompilation? As it turns out, improved performance is often brought as an evidence of the benefits of precompilation. While precompilation certainly saves users from the...
Microsoft Bridging VB6 And .NET Forms A new toolkit from Microsoft will allow VisualBasic 6 developers to craft .Net WinForms that can be displayed in a VB6 application. The Interop Forms Toolkit reported on eWeek.com should help VB6 developers...
ASP.NET: How To Create Custom Trace Messages This article is an excerpt from the book: Murach's ASP.NET 2.0 Web Programming with C# 2005. The Trace feature is an ASP.NET feature that displays some useful information that you can't get by using the debugger.
|
|
|
12.08.06
App_Code: Why It's Better
By
Mads Kristensen
I remember when ASP.NET 2.0 beta 1 was released about 2 years ago and I eagerly tried it out.
The first thing that struck me as strange was the new application folders like App_Code, App_Data, and App_Themes etc. They all made perfect sense except App_Code.
I didn't see the point of putting code in the folder because a separate assembly is a much cleaner approach.
After some weeks I finally got the point. It had nothing to do with putting code-behind files in it to make them globally accessible because that is just bad architecture.
No, it was much more important than that. It was about componentizing ones application to an even smaller degree than by using and reusing separate assemblies.
The App_Code folder allows me to use HttpModules, handlers, classes and other code pieces that don't naturally belong together in a separate assembly.
By now a have a pretty decent collection of code that I use for various different ASP.NET applications and I can simply pick just the ones I need and drop them into the App_Code folder.
That means that it is no longer necessary to reference a separate assembly and only use a couple of its classes.
That makes the application easier to debug and you know exactly what code pieces you use at all times - just look in App_Code.
In ASP.NET 1.x none of this has any meaning because all classes can be made globally accessible without moving them to some special location.
But in ASP.NET 2.0 this is a great way of abstracting components from the rest of the code.
That's why App_Code is better.
The only thing you have to do in order to get the full advantage is to start collecting reusable components.
About the Author: Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.
http://www.madskristensen.dk/
|