n-tier architecture with ASP.NET MVC – Introduction
As noted in the previous post – Introduction to n-tier architectures – I am following up with this tutorial on ASP.NET where we’ll introduce the framework, its components and how to use it. Passing by this article you will find the content of the rest of ASP.NET tutorials am posting relevant, as long as you’ll get the appropriate theories here before starting with the practice.
If you have no knowledge already about web applications, web frameworks or software architectures and you happened to find this post before any other starter post on ASP.NET, please do checkout out the following to get:
- What is a software architecture: on the first section of this introductory post on software architectures.
- What is n-tier architecture: on introduction to n-tier architecture post.
- What’s a framework : on the first section of this Symfony framework article.
If you are not that early in your web development learning process, or if you just finished with the links above, we can just start out with the ASP.NET web framework.
The .NET framework
Same as I introduced Symfony here as a “reusable set of standalone, decoupled, and cohesive PHP components that solve common web development problems and can be used to build dynamic websites, web applications, web services or resources. ” , I’d make it simple as possible for you to get what ASP.NET framework is !
ASP.NET is only two major components (the common language runtime and the .NET Framework class library) made for building several types of applications ranging from traditional command-line or graphical user interface (GUI) applications to applications based on the latest innovations provided by ASP.NET, such as Web Forms and XML Web services.
.NET framework components
The Common Language Runtime
This component manages memory, thread execution, code execution, code safety verification, compilation, and other system services. These features are intrinsic to the managed code that runs on the common language runtime. It also enforces code robustness by implementing a strict type-and-code-verification infrastructure called the common type system (CTS), and it accelerates developers productivity by supporting more tha one language.
The .NET framework class library
This component is a collection of reusable types that tightly integrate with the common language runtime. The class library is object oriented, providing types from which your own managed code can derive functionality. Also, third-party components can integrate seamlessly with classes in the .NET Framework. The .NET framework class library allows you to accomplish a range of common programming tasks such as string management, data collection, database connectivity ect…, and other specialized development scenarios like developing console applications, XML Web services, Windows services, Windows Forms applications, or ASP.NET applications.
This diagram presents the .Net framework 4.5 architecture. You can note the common language runtime and all of the .Net framework class libraries:
As you can notice in the diagram above, ASP.NET is one among the .NET framework libraries. In server side application development, ASP.NET is the hosting environment that enables developers to use the .NET Framework to target Web-based applications. But it is more than just a runtime host; it is a complete architecture for developing web sites and internet-distributed objects using managed code. Both Web Forms and XML Web services use IIS and ASP.NET as the publishing mechanism for applications. From the official documentation on MSDN ASP.NET is
the next generation technology for Web application development. It takes the best from Active Server Pages (ASP) as well as the rich services and features provided by the Common Language Runtime (CLR) and add many new features. The result is a robust, scalable, and fast Web development experience that will give you great flexibility with little coding.
ASP.NET AND MVC
It exists four programming models you can use to create ASP.NET web applications: ASP.NET Web Forms, ASP.NET MVC, ASP.NET Web Pages, and ASP.NET Single Page Applications. The ASP.NET MVC framework comes as an alternative to the ASP.NET Web Forms pattern for creating Web applications as it is a lightweight, highly testable presentation framework.
The MVC pattern helps you create applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements. If you are not used to the MVC pattern yet, I recommand you checkout the Basic cruds with Symfony tutorial part where I explained MVC in brief .
At this level we’d say enough to theories ! Let’s pass to the first tutorial n-tier architecture with ASP.NET MVC -: Entity Framework .