What is ASP.NET?

ASP.NET is a mature, server-side web development framework from Microsoft. Developers use ASP.NET to create dynamic websites, web apps, and web-based services. After decades of development, the framework persists today as ASP.NET Core.

The developer history of ASP.NET

Originally developed by Microsoft, ASP.NET now belongs to the .NET Foundation. While the first versions were still released as proprietary software, today’s modern ASP.NET is an open-source project.

The ASP.NET used today is the result of a decades-long development process. The evolution has taken it from ASP to ASP.NET to ASP.NET Core. In line with the progress of web technology, the framework underwent drastic changes over the years. Let’s first take a look at the development history of ASP.NET:

Technology Development environment Current version File ending
ASP Windows 3.0 / 2000-02 .asp
ASP.NET Windows 4.8 / 2019-04 .aspx/.aspx.cs, .aspx.vb etc.
ASP.NET Core Cross-platform 5.0 / 2020-11 .cshtml, .vbhtml, etc.
Tip

Create your own website without any programming know-how! With MyWebsite Website Builder from IONOS. It’s super simple.

Active Server Pages (ASP): Microsoft’s first server-side scripting language

The original ‘Active Server Pages’ (ASP) was the first server-side scripting language published by Microsoft. Active Server Pages let you create dynamic web pages on the server since 1996. Other scripting languages typically rely on Linux as the operating system and an open-source web server such as Apache. In contrast, Microsoft positioned Active Server Pages as part of the ‘Internet Information Server’ (IIS) running on Windows.

The basic functionality of ASP is roughly comparable with PHP or the ‘Java Server Pages’ (JSP). All three technologies use template files. These template files contain executable code snippets embedded in static HTML content. The code is written between special tags to separate it from the surrounding HTML. The programming languages used were the Microsoft-specific dialects VBScript, JScript, and PerlScript, which were available at the time.

When a URL is accessed by the browser (‘request’), the code is executed on the server. The execution generates HTML content that is inserted into the predefined HTML structures. The overall result is a document consisting of static and dynamically-generated HTML content; this is delivered as a response to the browser (‘response’) and displayed to the user. Any change to page content, such as user input, required a complete request-response cycle, in other words, a reload of the page. Here is an example of ASP code:

<p>
  The server’s current time:
  <%
    Response.Write Now()
  %>
</p>

ASP was not yet a framework. Rather, it used a loose collection of a handful of objects. From these, users were able to piece together a dynamic website:

  • Application
  • Request
  • Response
  • Server
  • Session
  • ASPError

ASP.NET: from the Active Server Pages to the Framework

ASP.NET, the successor to the classical ASP, was introduced around 2003. Instead of a loose collection of objects, the .NET Framework was used as a sub-structure. This abstracted commonly needed processes such as user authentication as well as authorisation and database access. In summary, ASP.NET is roughly comparable with Java frameworks such as ‘Struts’ or ‘Spring’.

As a crucial feature, ASP.NET included ‘Web Forms’. The Web Forms approach allowed experienced Windows developers to program dynamic web pages. This process meant that the web’s underlying mechanisms were hidden from developers; they could continue to use workflows and development environments with which they were familiar. More specifically, Microsoft-specific visual rapid application development (RAD) tools were used.

Web Forms provided Windows developers with a quick entry point into online programming. At the same time, however, the approach limited control over the HTML pages that were being delivered. ASP.NET MVC was soon added as an alternative development model. This followed the established ‘Model View Controller’ (MVC) pattern and allowed concerns to be separated more clearly. Based on the pioneering framework ‘Ruby on Rails’, ASP.NET MVC offered functionality for ‘scaffolding’ a project.

In the meantime, ASP.NET has been replaced by the further developed ‘ASP.NET Core’. In everyday language, however, both names are often used synonymously.

ASP.NET Core: new developments through an open-source license

With the release of ASP.NET Core, a change in the organisation of the framework took place. In the course of Microsoft’s progressive development, ASP.NET Core was placed under the umbrella of the .NET Foundation. The source code of the project is available under an open-source license.

On a technical level, ASP.NET Core is a re-design of ASP.NET 4.0, merging the organically grown components of ASP.NET. ASP.NET Core project development and hosting outside of the Windows ecosystem has been enabled. On Windows, ASP.NET Core is built on top of the .NET Framework; on other operating systems, the .NET Core Framework is used instead.

In line with the ongoing evolution of web technology, ASP.NET Core is ready for the cloud. ASP.NET hosting environments include open server environments as well as containers, in addition to Microsoft’s traditional Internet Information Server (IIS). The framework supports client-side code and modern approaches to responsive programming. This puts ASP.NET Core on par with JavaScript-based frameworks such as React.

What kind of projects is ASP.NET suited for?

Web projects of all kinds can be realised with the ASP.NET Framework. In particular, this includes dynamic websites and web applications, including ‘Single Page Apps’ (SPA). Furthermore, web-based services such as APIs and systems for real-time communication can be implemented. Over the years, different approaches have been used for the various purposes. We’ll discuss these below and provide an overview of their development.

Programming models in ASP.NET

While web technologies have advanced since the 2000s, new approaches to web development have also been integrated into ASP.NET. You can think of it like a well-sorted toolbox: Different tools are available for different kinds of projects. Depending on the requirements, several approaches can be combined within one project. With the release of ASP.NET Core, the numerous, organically grown programming models were merged. This led to a simplification of suitable approaches.

ASP.NET Web Forms

Classic Web Forms are used to assemble pages from predefined components. Here, a visual form builder is used that allows individual components to be positioned by drag-and-drop. This was particularly attractive for developers with experience in Windows programming. They could use the tools they were familiar with for ‘Rapid Application Development’ (RAD). The difference was that the end-product was not a Windows application, but a dynamic website.

The Web Forms approach is based on Microsoft’s ‘Code Behind’ model. This makes sure that concerns are separated:

  • Template files with the extension .aspx define the HTML structure of a page and contain placeholders for dynamically generated content.
  • The actual application logic is stored in a separate file with the extension .aspx.cs or .aspx.vb. This is the Code Behind file that gives it its name.
  • The client retrieves the .aspx file available in a URL. On the server, the static and dynamic components are combined. The resulting HTML document is delivered to the client.
  • When user input is received on the page, the data is transferred to the same URL via a GET or POST request and processed by the Code Behind file.

An object-orientated approach is used to implement the application logic: the Code Behind file defines a derived class. C# or Visual Basic is usually used as the programming language. Interestingly, the Code Behind file is precompiled once. This leads to faster execution and greater robustness against errors when the page is called up.

ASP.NET MVC

In contrast to the original ASP, Web Forms were a step towards separation of concerns. With ASP, static HTML and code components were mixed in one and the same file. With Web Forms, the separation into template and Code Behind files occurred. With ASP.NET MVC, ASP.NET got another programming model that allowed web development according to the Model View Controller (MVC) pattern.

The MVC pattern separates application logic (‘Model’), presentation template (‘View’), and user interaction (‘Controller’). One of the advantages of the MVC approach is that the individual concerns can be better tested. Furthermore, the separation of the concerns allows different controllers to be used. For example, instead of sending all user input to a single URL and reloading the page, AJAX via jQuery is used. This allows parts of the page to be reloaded. With ASP.NET Core MVC, the tradition of ASP.NET MVC continues into today’s version of the framework.

ASP.NET Web Pages

ASP.NET Web Forms and ASP.NET MVC are well suited for creating complex websites. If you need multiple pages with reusable components, both programming models are ideal. But what if you don’t need this? Let’s say we want to build a simple website that consists of only a single page or a handful of pages. There are a few dynamic components, but the focus is on a polished layout rather than complex application logic and processing user input. In that case, it would be overkill to define custom classes or aim for a split along the MVC pattern.

For cases where application logic is less important than a sophisticated layout and design, ASP.NET Web Pages are a good choice. Like classic ASP or PHP, a combination of static HTML structures and dynamic code components takes place within a file so that a special syntax is used. ASP.NET Web Pages are particularly well suited for the creation of landing pages.

ASP.NET Web API

The programming models presented so far all aim to generate HTML content for humans. However, the ASP.NET Framework also contains models that are used to provide infrastructure for web projects. ASP.NET Web API is a programming model for creating REST APIs. Access to the API endpoints takes place via AJAX. JSON or XML is used for data transfers.

ASP.NET WebHooks

ASP.NET WebHooks is an implementation of the WebHooks pattern. WebHooks lets you publish and subscribe to events that take place in a system. For example, this could be the addition of a file or the receipt of a payment. A subscriber registers the change to be tracked with the publishing system. To do this, they pass a URL – the namesake WebHook. When the registered event occurs, the publishing system calls the WebHook; the subscriber is informed about the event.

SignalR

SignalR is a framework for real-time communication between client and server. The framework is based on the WebSockets standard and allows the bidirectional transfer of data. Browsers that don’t support WebSockets are supported via fallback mechanisms. SignalR is often used to implement browser-based chat services and video conferencing software.

New programming models in ASP.NET Core

ASP.NET Core is the successor to ASP.NET. The ASP.NET Core framework has been rewritten, but has a high degree of compatibility with its predecessor. Previously separate components of ASP.NET were merged into the Core version. Furthermore, some components were redeveloped and retained their existing names. For example, the SignalR Framework exists in both ASP.NET and ASP.NET Core versions. Let’s take a look at the main new developments of ASP.NET Core.

ASP.NET Core MVC – API-driven model view controller sites

With ASP.NET Core MVC, functionalities of ASP.NET MVC and ASP.NET Web API have been combined. This enables the development of highly dynamic web applications with a modular user interface and underlying API. The .NET Core Framework is used as the common foundation. Familiar approaches from .NET API development can be transferred to MVC development and vice versa.

Razor Pages – further development of ASP.NET Web Pages

Razor Pages fill a similar niche as the former ASP.NET Web Pages. They can be used when the Model-View-Controller pattern represents unnecessary overhead. For example, if you want to build a landing page, it can be implemented as a Razor Page with little effort. The Razor syntax is used to create the page template. As is typical in the .NET universe, C# and Visual Basic can be used as programming languages.

Let’s take a look at an example Razor page. It is noticeable that instead of the usual opening and closing code tags in template languages, an opening @ character is used:

@page
@model HelloWorldModel
 
@if (Name != null) {
    <p>Hello dear @Name</p>
}
<form method="post">
    <p>
        <label asp-for="Name"></label>
        <input class="form-control" asp-for="Name" />        
    </p>
    <input type="submit" value="Say Hello" />
</form>       

Reactive programming with Blazor – ‘NET in the browser’

The Blazor framework relies on the aforementioned Razor syntax; in fact, Blazor stands for “‘Browser + Razor”’, As the name implies, the focus of Blazor is on the browser as a runtime environment. With Razor Pages, the processing of user interaction takes place on the server. Blazor, on the other hand, enables reactive programming, where individual page components in the browser react dynamically to changes. This makes Blazor roughly comparable to React, Angular, and Vue technologies.

Here’s a simple example of reactive programming with Blazor. We bind the value of an input field to the variable Name. The Razor syntax is used for this:

@page "/"
<h1>A Blazor example</h1>
<p>Welcome to Blazor, @Name.</p>
<input bind="@Name" type="text" class="form-control" placeholder="Name" />

In addition to reactive programming, another feature of Blazor is highly interesting: Via WebAssembly, the .NET languages can be compiled for execution in the browser. Blazor is therefore sometimes also referred to as an approach for ‘.NET in the browser’. The advantage is not having to write JavaScript for the client-side code. Instead, development is done in C# or Visual Basic; the code can access the familiar components of the .NET framework.

What are the advantages and disadvantages of ASP.NET?

ASP.NET or ASP.NET Core provides a mature environment for developing a wide variety of web projects. The scope includes programming languages, code editors, and IDEs, as well as development tools and a thriving ecosystem of freely available packages. Nowadays, modern methods such as reactive programming, WebSockets, and WebAssembly are used. Traditionally, the biggest drawback to using ASP.NET has been its close ties to Microsoft and the vendor lock-in that comes with it. With the progressive move towards open source, this is now less of a concern.

What are the advantages of ASP.NET?

The biggest advantage of using ASP.NET is drawn by developers who are familiar with programming in the Microsoft ecosystem. They can comfortably access the languages, tools, and workflows they are familiar with. The mature .NET Framework is used as the foundation of ASP.NET. This means, that suitable components are available for a large number of use cases. This is a great advantage when it comes to implementing complex applications quickly and with reliable results.

The .NET Framework has a modular structure and features the ‘Common Language Runtime’ (CLR) as a runtime environment. This allows the use of various programming languages as long as they comply with the Common Language Infrastructure (CLI) standard. The CLI languages developed by Microsoft include the object-orientated classics C# and Visual Basic as well as the newer functional language F#. Using Blazor and WebAssembly, the CLI languages can be executed as client-side code in the browser.

Originally, ASP.NET began as proprietary software under the control of Microsoft. Today, it is an open-source project under the .NET Foundation. As part of this opening, the NuGet package manager and associated public package repository were established. Comparable to NPM or RubyGems, ASP.NET developers have an ecosystem of freely usable packages at their disposal.

What are the disadvantages of ASP.NET?

The biggest advantage of ASP.NET – the use of the Microsoft-specific ecosystem – is also its main disadvantage. That’s because web development is otherwise largely built on free and open platforms, languages, and formats. Developers diving into the .NET universe for the first time are presented with a bewildering array of versions and programming models.

Traditionally, those who wanted to develop with the ASP.NET Framework could do so only on Windows. For years, Microsoft has been ramping up an effort to open-up to widely used standards and open source. With the release of ASP.NET Core, development now works on the three major operating system: Windows for families, macOS, and Linux. Furthermore, it’s now possible to store the development environment in a Docker container.

Classic ASP.NET could only be hosted on Microsoft’s in-house server technology Internet Information Server (IIS). This was a major disadvantage compared to other web frameworks, all of which also run on Linux. ASP.NET hosting has special requirements and is not available from all providers. It was possible to use other web servers with ‘Mon’ as a free .NET implementation. However, the real change came with the release of .NET Core and the ‘Open Web Interface for .NET’ (OWIN). OWIN dissociates an ASP.NET application from the underlying web server. This removed one of the biggest hurdles to using ASP.NET.

What are the requirements for the APS.NET hosting environment?

The ASP.NET framework is special in terms of the hosting environment. Other web frameworks based on the PHP, Java, Python, or JavaScript languages all run on Linux servers. Only hosting ASP.NET applications traditionally required Windows as the server operating system. It was also mandatory to use Microsoft’s Internet Information Services (IIS) web server. To host an ASP.NET application on Windows servers, you should pick Managed Windows Hosting. With this hosting model, your servers are maintained by the provider and regularly updated.

Hosting ASP.NET core applications is much more relaxed. These can be hosted on a variety of server environments in addition to IIS. The integrated Kestrel web server is used, which runs on Windows, Linux, and macOS. Popular web servers such as Nginx and Apache can be configured as reverse proxies in conjunction with Kestrel. On Windows, the Kestrel alternative HTTP.sys is also available.

Tip

Use ASP.NET hosting from IONOS!


Wait! We’ve got something for you!
Get your .co.uk domain for just £1/1st year.

Enter the web address of your choice in the search bar to check its availability.
12 months for £1
then £10/year