Skip to content
  • iImagine
  • Register
  • Log In

Web Development School

Learning made easy.

  • Books
    • Beginning Web Development with ASP.Net Core & Client-Side Technologies
      • TOC
      • Part 1
        • Chapter 1: Static HTML – Designing the landing page
      • Part 2
        • Chapter 2: ASP.Net Core – Let’s talk Dynamic
        • Chapter 3: Introduction to ASP.Net Core MVC
          [ASP.Net Core v9]
      • Part 4
        • Chapter 7: Using Server Side & Client Side technologies together
          [ASP.Net Core v7 & Angular 15]
  • Environment Setup
    • Installing Angular
    • Installing Visual Studio 2022
    • Installing SQL Server 2022 Express
    • Installing Postman
    • Installing Git for Windows
  • Blog
  • iImagine WebSolutions
  • Events
  • Learning Videos
  • Toggle search form

What is ASP.Net

Table Of Contents
  1. Introduction
  2. History of ASP.Net and ASP.Net Core
    • Classic ASP
      • Data Access with ADO
    • ASP.Net
      • First came Web Forms
        • Data Access with ADO.Net
      • Then came MVC
        • MVC (Model-View-Controller)
        • Data Access with Entity Framework
    • ASP.Net Core
      • Three Frameworks?
  3. What's Next

Introduction

We noted in the last module that the idea behind the .Net Core Framework is that you can build any type of application be it web, mobile, desktop, and many more by learning just one Framework; .Net Core.

ASP.Net Core is the specific part of the .Net Core Framework that let’s us build web applications. ASP.Net Core will be the main focus of this book going forward.

You can read more about the ASP.Net Core platform at the Microsoft Official ASP.Net Core documentation start page:
https://dotnet.microsoft.com/en-us/apps/aspnet

A good place to start reading through the documentation is the overview page. From the navigation on the left hand side of the documentation you can find many tutorials on each of the technologies included within ASP.Net Core in subsections such as Web apps, APIs, and Data Access.

History of ASP.Net and ASP.Net Core

Before the rewrite of windows to windows.net, and before .Net and ASP.Net, Microsoft had a scripting language called ASP (Active Server Pages).

Classic ASP

These days we refer to the original version of Active Server Pages as Classic ASP. Before languages for creating dynamic web pages like ASP, PHP, and Cold Fusion, all we had was Static HTML, like what we used in Chapter One to create the Fred’s Cars Web Pages. And we’ve already noted the problems and limitations with Static HTML. Chapter One was just a way for us to get our head around the basic building blocks of web development; HTML, JavsScript, and CSS.

ASP came out around 1998 and was a simple but eloquent and powerful language for creating dynamic web pages.

ASP runs on a web server. So when you type a url into your browser such as www.fredscars.com/vehicles.asp, your browser sends a request to the vehicles asp page running on the computer server named www in the fredscars subdomain within the .com internet domain. This is an oversimplification. But, the point is that your browser is sending a request to the server at this URL address. The asp worker process running on the web server intercepts the request, dynamically builds the HTML for the web page at the server, and sends it as a response back to the browser.


There were only five objects in Classic ASP which kept it simple but gave us the power to control the most common aspects of a web application such as requests and responses. The five objects were:

  1. Application: used to store and access global variables from any page. All users share one application object.
  2. Request: used by a web page to get information for a visitor via cookies, form post, or query string values.
  3. Response: used to send output to the user from the server.
  4. Server: used to access properties and methods on the server.
  5. Session: stores information or settings about a particular user. Similar to the Application object but specific to one user.

Data Access with ADO

In Classic ASP, we would access the data from a database for our dynamic web pages using an Active-X object called ADO (Active Data Objects).

ADO was pre-installed on a Microsoft Server bundled with IIS (Internet Information Server).

The following is an example of what it might look like to use ASP and ADO to access some vehicle data from a database and create a dynamic web page for Fred’s Cars from the server.

<html>
<body>

<h1> Welcome to Fred's Cars!</h1>

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/data/fredscars.mdb"

set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM Vehicles", conn

do until rs.EOF
  for each vehicle in rs.Fields
    Response.Write(vehicle.vin)
    Response.Write(", ")

    Response.Write(vehicle.make)
    Response.Write(", ")
    Response.Write(vehicle.model)
  next
  Response.Write("<br>")
  rs.MoveNext
loop

rs.close
conn.close
%>

</body>
</html>

Don’t worry if you don’t understand the above code sample. The point here is that with Classic ASP we could intersperse ASP code in with the HTML to create a dynamic web page. In the above code we have a regular <h1> heading element giving a welcome message and then the ASP building a dynamic table of data is demarked by the “<%” and “%>” characters.

ASP.Net

With the rewrite of Windows to Windows.Net, Microsoft came out with the first version of ASP.Net in January of 2002.

People often refer to the ASP.Net Framework. But I think of it more as a platform that gives us access to pre-built components of common web development tasks like Data Access, Membership, and Security (Authentication and Authorization).

First came Web Forms

When the ASP.Net Platform first came on the scene it only offered one framework for developing web applications; Web Forms.

The idea behind Web Forms was that any programmer could develop web pages and applications without having a lot of knowledge about web development or how the web works. They could just drag and drop Server controls and HTML controls from a toolbox to the design area and Visual Studio would generate the code. You were also free to write the code yourself if you wished and the design area would be updated. There was a split view available where you could see a WYSIWYG (What You See Is What You Get) view of the design on the bottom and the HTML code on the top as in the following image from Code Magazine.

To make an HTML element a Server-Side control you would include a runat=server attribute as shown for the following input element.

<input type="text" value="hello world" runat=server />

The Server-Side controls could keep state between postbacks like the text value of the input element.

The above is an example of an HTML Server Control. But Web Forms also had Web Server Controls. An example is shown below:

<asp:textbox text="hello world" runat=server />

Web Server controls are more rich than HTML Server controls. The above asp:textbox server control might have a property of whether to render as a text input element or a multiline textbox element.

Web Forms also introduced the idea of separating presentation from code by keeping the HTML in a file with an “.aspx” file extension (active server pages – where x stands for .Net) and the C# code in a code behind file with a “.cs” (CSharp) file extension.

But, you could combine the HTML and C# code into one file if you wanted to.

Here is an example of what a single file version in Web Forms might look like for a fredscars.aspx page that displays vehicle data.

<%@ Page Language="C#" %>
<html>
    <head id="Head1" runat="server">
        <title>Fred's Cars</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>

                <asp:GridView
                    id="grdVehicles"
                    DataSourceID="srcVehicles"
                    Runat="server" />

                <asp:SqlDataSource
                    id="srcVehicles"
                    SelectCommand="SELECT Vin, Make, Model, Color, Price
                        FROM Vehicles"
                    Runat="server" />

            </div>
        </form>
    </body>
</html>

In the code above you can see Web Forms are programmed using an approach called declaritive programming. This means that instead of typing out a table, tr, th, and td elements by hand to lay out the data, we can use an ASP.Net Web Server control called a GridView. And the GridView control uses as its datasource another Web Server control called an SqlDataSource.

Data Access with ADO.Net

The SqlDataSource control in the above example actually uses ADO.Net under the hood. Just as Classic ASP progressed to its next evolution of ASP.Net so to did ADO to ADO.Net

And just as ASP.Net is the part of .Net that allows us to build web applications, ADO.Net is the .Net Framework library containing the main set of classes that enable us to work with database data.

ADO.Net supports two models of data access; connected and disconnected. The main classes for the connected model of data access are Connection, Command, and DataReader. The classes for the disconnected model are DataAdapter, DataTable, DataView, and DataSet which can be used to create an in-memory representation of the database.

All of the ADO.Net classes listed above are just base classes. To access data from a specific database like SqlServer or Oracle you have to use the implementations of these classes from the database Provider you need.

For example, the code for a C# class accessing Vehicle data from an SQL Server database using ADO.Net might look something like the code below.

Vehicle.cs

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration
using System.Collections.Generic;

public class Vehicle
{
	private static readonly string _connectionString;

	private string _vin;
	private string _make;
	private string _model;
	private string _color;
	private double _price;

	public string Vin
	{
	    get { return _vin; }
	    set { _vin = value; }
	}

	public string Make
	{
	    get { return _make; }
	    set { _make = value; }
	}

        public string Model
        {
            get { return _model; }
            set { _model = value; }
       }

        public string Color
        {
            get { return _color; }
            set { _color = value; }
        }

        public string Price
        {
            get { return _price; }
            set { _price = value; }
        }

	public List<Vehicle> GetAll()
	{
		List<Vehicle> results = new List<Vehicle>();
		SqlConnection con = new SqlConnection(_connectionString);
		SqlCommand cmd = new SqlCommand("SELECT Vin, Make, Model, Color,Price FROM Vehicles", con);

		using (con)
		{
		    SqlDataReader reader = cmd.ExecuteReader();
		    while (reader.Read())
		    {
			Vehicle newVehicle = new Vehicle();
			newVehicle.Vin = (string)reader["Vin"];
                        newVehicle.Make = (string)reader["Make"];
                        newVehicle.Model = (string)reader["Model"];
                        newVehicle.Color = (string)reader["Color"];
                        newVehicle.Price = (double)reader["Price"];
                        results.Add(newVehicle);
                    }
		}
		return results;
	}

	static Vehicle()
	{
	    _connectionString = WebConfigurationManager.ConnectionStrings["Vehicles"].ConnectionString;
	}
}

The code above uses the connected model of ADO.Net to access Vehicle data from a database as you can see from the SqlConnection, SqlCommand, and SqlDataReader objects being used. Using the connected model of ADO.Net in this manor is known as the firehose method because it just fetches the data and sprays it out super fast like a firehose. It doesn’t have the overhead of setting up the in-memory database like the disconnected model does.

Now to utilize the new Vehicle class we could replace the SqlDataSource Server control on the Web Form with an ObjectDataSource and point it’s TypeName property to Vehicle and SelectMethod property to GetAll().

fredscars.aspx

<%@ Page Language="C#" %>
<html>
    <head id="Head1" runat="server">
        <title>Fred's Cars</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>

                <asp:GridView
                    id="grdVehicles"
                    DataSourceID="srcVehicles"
                    Runat="server" />

                <asp:ObjectDataSource
                    id="srcVehicles"
                    TypeName="Vehicle"
                    SelectMethod="GetAll"
                    Runat="server" />

            </div>
        </form>
    </body>
</html>

Again, don’t worry if you don’t understand everything in the code above. This is not a book about Web Forms. We’re just taking a whirl wind tour here of the technologies that led up to ASP.Net Core.


You can see ASP.Net Web Forms were a very powerful way to program in their time. But over time certain problems began to rear their ugly heads as usual. For one thing, each server control maintains its ViewState for each postback. And the ViewState for the entire page can become very large, take up a lot of bandwidth, and slow down the application.

Another problem was that Web Forms put an abstraction layer over the way HTTP and HTML work so that the developer doesn’t have to understand the details. This can seem like an advantage at first and enable us to widen our talent pool of web developers but it creates a complex life cycle for each page and I can tell you I spent a lot of evenings trying to get something to work by hacking the life cycle and page events. It was frustrating because coming from classic ASP I understood how the web works but sometimes it could be difficult to cut through the same Web Forms development details that were supposed to make life easier.

Never the less ASP.Net Version 1 and Web Forms were a huge breakthrough in Web Development, embraced by a large part of the development community, and set the stage for the next two decades to come.

Then came MVC

As already noted, in Version 1 of ASP.Net there was only one framework offered to create web pages and applications; Web Forms. And we have already discussed the problems with that paradigm.

ASP.NET MVC was first released in 2009 as an alternative web development framework to Web Forms. MVC is a popular software development pattern and Microsoft implemented it’s own version of it for ASP.Net.

ASP.Net MVC is Microsoft’s proprietary implementation of the MVC software development pattern, which happens to lend itself well to web development, and also has access to all of the already existing components ASP.Net has become famous for like Membership, Security, Data Access, and so forth.

ASP.Net MVC also returned control over the HTML back to the developer. The Developer typically writes out the HTML interspersed with C# and Razor Syntax all within a Razor View (Stay tuned for Chapter Three to start learning all about Razor).

MVC (Model-View-Controller)

We will get more into what MVC is really all about in the next chapter. But for now, MVC stands for Model-View-Controller.

An MVC application is broken into three tiers, taking it a step further than the Web Forms concept of separating content from presentation in only two tiers.

  • Model: Contains the business rules and provides access to the database for the controller.
  • Controller: Controls application flow. Receives the incoming URL request and sends CRUD (Create, Retrieve, Update, and Delete) requests to the Model, and provides the View with a Model of data to display.
  • View: Responsible for rendering the data model sent from the controller in HTML to the user.

The following diagram shows the flow of a web application between the three MVC components, the browser, and a user.

Data Access with Entity Framework

In ASP.Net MVC the typical way of accessing data moved away from using ADO.Net by hand to using Entity Framework. Although, MVC is very flexible and any component (Model, View, or Controller) or method of data access can be customized or replaced.

Entity Framework is an ORM (Object Relational Mapping) tool that allows us to map C# objects which represent our domain to tables and columns in the database. We use these C# objects called POCOs (Plain Old CLR Classes) to define our domain model. And we use this model to create queries to the database using a technology called LINQ.

We will take a closer look at what Entity Framework is all about in the next module. And, we will get to see plenty of examples using Entity Framework Core and LINQ in the next chapter when we start learning ASP.Net Core MVC.

ASP.Net Core

Microsoft came out with ASP.Net Core in 2016 with Visual Studio 2015.

ASP.Net Core is able to run different versions side-by-side which we’ve noted could not be done with .Net Full-Framework. You could only run one version of .Net Full-Framework on a serer at a time.

Honestly the flavor and feel of ASP.Net Core MVC is almost identical to programming in ASP.Net MVC Full-Framework.

One of the biggest changes is in configuration. Instead of having to deal with the dreaded XML based Web.config file, configuration settings are now in an easier to read JSON file called app.settings making ASP.Net Core applications cloud ready.

Also, as noted earlier, every piece of functionality you use from ASP.Net Core has to be downloaded in a nuget package avoiding having to load the gargantuan system.web.dll for every web application. If you want to use EF Core, you have to add the Microsoft.EntityFrameworkCore package. If you want to use LINQ (Language Integrated Queries) you have to add the System.Linq nuget package. Rest assured, we will learn how to do this and become very proficient at it in Part 2, Chapters 3, 4, and 5.

Three Frameworks?

With Web Forms gone in the ASP.Net Core platform, the only remaining web development framework was MVC Core; Until 2017 that is. Microsoft came out with an alternative to MVC with ASP.Net Core 2.0 called Razor Pages.

Razor Pages are very similar to MVC and can be thought of as MVC light. Razor Pages run on top of MVC. Razor pages do not have a controller but have a code behind file that acts as the model to the front end file. The front end file has a .cshtml file extension and the code behind model file has a .cshtml.cs file extension. This can make some of us coming from Web Forms a little uneasy and think, “What are you doing Microsoft? Returning to code behind files and the dreaded Web Forms paradigm of the past?” But, don’t worry. Razor Pages is a nice framework and is actually built on top of MVC. And Razor Pages is easier to learn than MVC for those new to the ASP.Net Core Framework. Razor Pages retain many of the characteristics that made MVC popular like Dependency Injection making its components easier to test and maintain.


Microsoft came out with a third framework in 2019 with ASP.Net Core 3 called Blazor.

Blazor is a framework for creating single page applications and is Microsoft’s answer to other client-side JavaScript frameworks like Angular, React, and Vue.js.

But with Blazor, you don’t have to learn JavaScript. You can use C# to program the client-side. And we can use C# to share code logic between the server-side and front-end.

What’s Next

We will have a chance in Part Two to visit and explore each of these three frameworks.

In Chapter Three we will upgrade the HTML version of Fred’s Cars to MVC.

In Chapter Four we’ll see how we can modify our web application to run as a Razor Pages applicaton.

And in Chapter Five we will write Fred’s Cars as a Blazor SPA (Single Page Application).

But, before moving on, let’s take a closer look what Entity Framework Core is all about in the next module.

< Prev
Next >

Leave a ReplyCancel reply

Chapter 1: Static HTML – Designing the landing page.

  • Static HTML – Designing the landing page.
  • Let’s get started!
  • Mock your site with HTML
  • Make CSS easy with Bootstrap
  • Mock your content
  • Introducing JavaScript
  • JavaScript Code Improvements
  • Results Data
  • Images and the HTML Image Element.
  • Revisiting Reusability for CSS and JavaScript
  • Reuse for HTML: PART 1
  • Reuse for HTML: PART 2
  • Details Page – Using a Bootstrap Component
  • Creating Links
  • Chapter One Conclusion

Chapter 2: ASP.Net Core – Let’s talk Dynamic

  • Introduction to ASP.Net Core
  • What is .Net?
  • What is ASP.Net
  • Introduction to Entity Framework Core

Chapter 3: ASP.Net MVC Core – Models, Views, and Controllers [ASP.Net Core v9]

  • Introduction to ASP.Net Core MVC
  • Create the project: ASP.Net Core MVC
  • Explore the ASP.Net Core Empty Web Project Template
  • Configure the Application for MVC
  • Create a Controller: Home Controller
  • Create a View: Index View for the Home Controller
  • Install Bootstrap using Libman
  • Create the Layout template
  • Create the Model
  • Install EF Core & Create the Database
  • Seed the Database: Loading test data
  • DI (Dependency Injection): Display a List of Vehicles
  • Repository Pattern: The Vehicles Repo
  • Unit Test 1: Home Controller Can Use Vehicle Repository
  • Unit Test 2: Vehicle Repository Can Return List
  • Add the ImagePath Migration and Thumbnail images to results
  • Pagination: Create a Custom Tag Helper
  • Sorting
  • Category Filter
  • Partial View: Break out the vehicle results
  • View Component: Create dynamic category buttons
  • Create the Details page
  • Create the Create Page

Chapter 7: Using Server Side & Client Side technologies together. [ASP.Net Core v7 & Angular v15]

  • Intro to Full Stack Development
  • Fred’s Cars – Full Stack Development
  • Prepare the environment
  • Create the Visual Studio Solution
  • Add the ASP.Net Core Web API project
  • Add the Angular Project
  • Wire it up!
  • WeatherForecast: Understanding the basics
  • Vehicles API Controller: Mock Data
  • Vehicles Angular Component: Consuming Data
  • Routing and Navigation
  • Using a Component Library: Angular Material
  • Our first Angular Material Component: MatToolbar
  • Configuring for Saas: CSS with superpowers
  • Create the Header & Footer components
  • Displaying Results with MatTable
  • Loading: Using a Progress Spinner
  • MatTable: Client-Side Paging and Sorting
  • MatSidenav: Create a Search Sidebar
  • MatCheckbox: Category Search UI
  • Adding an image to the welcome page
  • Create the database with Entity Framework Core migrations
  • MatPaginator & PageEvent: Custom Server-Side Paging
  • Unit Testing: Custom Server-Side Paging
  • Repository Pattern: VehicleRepository
  • Unit Test: Paging in the Vehicles controller
  • Server-Side Sorting
  • Unit Tests: Sorting
  • Filter (Quick Search)
  • Unit Tests: Filter feature
  • Advanced Search: Categories
  • Unit Tests: Search by category
  • Progress Spinner: Final Fix

TOC

  • What were WebForms?
  • Enter MVC
    • Understanding MVC
    • Advantages of MVC
  • ASP.Net Core MVC – A total rewrite
  • ASP.Net Core 2 MVC – Here come Razor Pages
    • Understanding Razor Pages
  • ASP.Net Core 3 – Dropping the MVC reference
    • Understanding Blazor
  • Dropping the MVC reference
  • Hello .Net 5!
  • What’s Next? – Here comes .Net 6.

Recent Posts

  • Angular Commands Cheat Sheet
  • Installing Git for Windows
  • Installing Postman
  • Installing SQL Server 2022 Express
  • Installing Visual Studio 2022

Recent Comments

No comments to show.

Archives

  • November 2023
  • October 2023
  • June 2023
  • October 2021

Categories

  • Angular
  • ASP.Net
  • Environment Setup
  • See All
  • SQL Server
  • Visual Studio
  • Web API & Rest Services

WordPress Theme Editor

Copyright © 2025 Web Development School.

Powered by PressBook Blog WordPress theme