Reading Time: 12 minutes

Introduction to ASP.NET/.NET Core

.NET is an incredibly powerful software development framework created by Microsoft and used by some of the largest enterprise environments in the world. Originally created in 2002, it was decided to supersede Active Server Pages (ASP Classic 3.0). While .NET is very versatile it is also very “corporatey” because of its tight integration within the Windows environment. .NET is most commonly used in corporations because it’s easily integrated with Active Directory and allows for rapid and easy development of internal business apps. .NET is also suitable for a wide variety of things such as web applications, console apps, Windows services and as of recently cross-platform development with .NET core.

The Programming Languages of .NET

ASP.NET is primarily C# and Visual Basic (VB.NET), however, there is F# and support for other languages like C++. There are also extensions to allow Visual Studio, the IDE of .NET, to work with other languages such as PHP or Python.

If you are new to .NET, C# is the only one you should focus on. Visual Basic is a dying language and no one adopts this and is commonly found in legacy applications. There is some worth in learning VB but I don’t recommend it unless you are porting legacy applications to modern C#.

General Compiler Process

A lot of this is changing from ASP.NET to .NET core. In general, the idea is that the .NET compiler will compile all programming languages down to a Common Intermediate Language (CIL) that will be executed as machine code (native code) when executed.

I would suggest reading up on this…

Common Language Runtime (CLR), the virtual machine component of the .NET framework that allows Just-in-time compilation (JIT) to convert managed code to machine code.

Common Intermediate Language (CIL) formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL).

Visual Studio

The official IDE of .NET is Visual Studio. This comes in several versions including Community, Professional, and Enterprise. The pricing on Enterprise is very expensive, it’s about $250 dollars per month. It does come with some very advanced functionality that you can’t get in the community or Pro editions. One of the features that I miss out on while using Pro that is only available in Enterprise is the ability to stub and fake dependencies for unit testing.

CommunityProfessional (I use this…)Enterprise
FREE$50/month$250/month

(I dream that one day my blog will pay for a Visual Studio Enterprise license.)

Visual Studio Code

An alternative to Visual Studio is Visual Studio Code which is a cross-platform, completely free, language-agnostic and extremely versatile IDE that supports .NET. Visual Studio Code can be used for many things such as web development, Python, C, C++, and many other languages because it has extensions.

C# (C-Sharp)

The programming language that is most widely used in the .NET Framework is C#. I strongly recommend that you learn and use C# over other programming languages within .NET. It’s relatively easy to learn and is similar to C/C++ and Java. C# is an object-oriented programming language that is very modern. The majority of the .NET job opportunities out there will require that you know C#.

This article is not about learning the syntax of C#, it is about the .NET Framework.

https://www.w3schools.com/cs/

ASP.NET vs .NET Core

ASP.NET will become the legacy .NET Framework while .NET core takes over. There came a point when Microsoft made one of it’s best decisions with the ASP.NET Framework; they decided to become completely cross-platform and open source. To accommodate this, ASP.NET would have to be completely re-written from the ground up. This meant they would have to decouple ASP.NET from the Windows System libraries so that it could run on other platforms like Linux. With the rebirth came a new name, .NET Core.

ASP.NET Framework 1.0

Originally released on January, 16th 2002, ASP.NET brought a fresh new set of features to developers. It originally included ASP.NET Web Forms which allowed for a Simple UI that developers could create web components that had code click behinds. This was very familiar to developers who did Win Forms applications.

ASP.NET MVC 1.0

Module View Controller (MVC) has been a software design pattern that has been around since the 1970s believe it or not. It was first introduced into Smalltalk-79 but didn’t gain popularity until it was brought into web development. MVC is now one of the most popular framework patterns for modern web development. ASP.NET MVC 1.0 was officially released on March 13th, 2009. This was a dramatic improvement over ASP.NET Web Forms and offered the first modern approach to web development.

.NET Core

The initial release date of .NET Core was June 6th, 2016. As of writing this, the current release version is .NET Core 3.1 and is really taking off.

Why is .NET core better than the ASP.NET Framework?

  • Performance
  • Cross-platform
  • portable

Performance

The performance of .NET core is amazing. When they decoupled .NET from the Windows libraries it became incredibly faster.

Just to give you an idea of how fast .NET core is, Raygun dumped Node.js for .NET core and increased their throughput by 2,000 percent.

.NET Core is Cross-platform

The biggest challenge right now is that the industry is transitioning from the legacy mindset of the ASP.NET Framework to the .NET Core Framework. The majority of libraries have not been ported to .NET core. While .NET core supports legacy libraries you can’t run legacy libraries in a cross-platform environment. I assume with time people will abandon and re-write code in .NET core. It’s only a matter of time before it’s easy to write fully cross-platform code.

Portability of .NET Core

.NET is very portable and can run without using Internet Information Services (IIS). Depending on the project a .NET core application can run on Linux.

At my current job, we are running .NET Core in Docker containers to integrate Kafka consumers and producers; orchestrated by Kubernetes in a Linux environment.

The Frameworks & Projects

The .NET Framework is amazing and can do so much more than most developers realize. I’m going to highlight the technologies I’m familiar with. If I miss something leave a comment.

ASP.NET Win Forms

Win Forms is a framework for building Windows applications, hence the name “Win Forms”. However, with the development of .NET Core, Win Forms applications will become cross-platform.

(Desktop application development with Win Forms)

Windows Presentation Foundation (WPF)

The Windows Presentation Foundation (WPF) allows developers to create desktop applications through a unified programming model. Instead of using a Form Designer you will be using a Designer that uses XAML. WPF came after Win Forms and offers several advantages. It is vector based so images, buttons and UI components scale easily to any size. The applications look better because it has built-in support for animation. The downside to using WPF over Win Forms is that it takes more effort and time.

ASP.NET Web Forms

A legacy solution that allowed the rapid development of a web application using the Simple UI. This is solutions include Windows Form Controls and components that make it easy to develop an internal business web application. This solution does not use modern JavaScript frameworks and uses postbacks to pass data.

ASP.NET/Core MVC

The MVC framework became extremely popular around 2010. I remember all of the hype, even scripting languages like PHP based their frameworks around the MVC design pattern. Now, with .NET the MVC framework included a lot of functionality that made web development much easier. Some of this included validating form data through data annotations on models.

(.NET Core MVC)

Console Applications

With .NET core you can now create cross-platform console apps that run on Linux. Console apps can be created and used to interact with services and processes.

(Windows Console Application in .NET Core)

Windows Communication Foundation (WCF)

Windows Communication Foundation (WCF) is a framework for creating service-oriented applications. The ASP.NET Framework has a lot of support for WCF and the biggest benefit I have experienced from using this is that it makes creating and consuming services within a .NET environment easier.

Some of the other features include:

  • Service Orientation
  • Interoperability
  • Data Contracts
  • Security
  • Multiple Transports and Encodings
  • Transactions
  • AJAX and REST Support
  • Extensibility

Web API & Single Page Apps (SPAs)

As web development progressed there came a need for more modern RESTful APIs within .NET. The Web API framework is the most modern approach in .NET to creating an API service. Using method attributes it’s easy to create routing paths and in general, Web API is like a Controller that is specifically designed to be stateless. Web API controllers also differ in which they use HTTP verbs to handle different requests.

Using Web API is very useful in modern web development because it’s practical for creating Single Page Apps (SPAs). These types of websites are built using reactive JavaScript frameworks like ReactJS/Redux, Angular and VueJS.

(Web API Controller)

Windows Services

Creating a Windows Service Application is a great way to have code that is managed by the Windows service manager. This results in the process being restarted if it fails, ran during startup and if the system is rebooted.

Dynamic Libraries

.NET allows for the creation of reusable dynamic libraries (DLLs) that can be shared across applications. This is really useful for porting code to different applications.

Azure Functions

With cloud computing really increasing in popularity it’s important to understand how serverless infrastructure works. Azure Functions provide the ability to place scripts in the cloud and have them run. Using Azure Functions it’s easy to create APIs that run in the cloud on serverless infrastructure.

Xamarin

Originally created by a 3rd party company and purchased by Microsoft, Xamarin is an open-source mobile app platform for .NET. It allows for the easy creation of apps that are cross-platform and visually impressive. Using Xamarin Forms to build cross-platform UIs allows the backend code to be reused across multiple platforms. With Xamarin you can build Windows, iOS and Android apps using C#.

(Xamarin Mobile App)

Advanced Techniques

People who are new may have no idea how to achieve high skill sets in .NET, but it really comes down to time and patience. Being in multiple environments and working with different applications, integrations and teams will develop strong skillsets. These are some of the things a developer will learn along the way. It takes about 10+ years to master anything and there are no shortcuts. Having awareness will increase the likelihood of becoming very talented in software.

Dependency Injection

This has become the norm within application development. Inversion of Control (IoC) follows the concept of removing dependencies from your code. By using interfaces and a Dependency Injector to automatically inject concrete classes for your interfaces, code becomes more open to unit testing and being more modular; which leads to easier management and development.

Object Relation Mappers (ORMs)

Object Relation Mappers (ORMs) are a way to easily and programmatically interface a database. There are many ORMs that you can find in the .NET ecosystem but some of the more popular ones are Entity Framework, Dapper, and NHibernate are the big ones. The interesting thing about these, they are wildly different.

Entity Framework

Entity Framework is an ORM created by Microsoft and provides multiple ways of interfacing with a database. There are two solutions they provide: Database First or Code First. With Database First, you can create your model classes from an existing database. This can be more cumbersome of a process because it creates models after the fact and you have less control over the process. There is a lot of autogenerated code. Code First is the best approach in my opinion because it gives the developer the ability to create their model classes first and is more decoupled from the database solution. There is also the Fluent API which helps Entity Framework understand relationships within the database.

Dapper

I don’t think there has ever been an ORM as powerful as Dapper. Created by Stack Exchange, this has become one of the most popular ORMs for .NET because of its incredible features. With Dapper, you have the most control. Interfacing stored procedures are easy and Dapper provides the ability to accept multiple sets of data from a stored procedure which is unheard of in other ORMs.

NHibernate

Worth mentioning is NHibernate because a lot of projects still depend on this ORM. This ORM has been around for many years and is very mature.

.NET Authentication

Authentication and authorization with any programming language or framework can get rather complicated. This is not an easy topic and takes an enormous amount of time to truly master. There are many configurations like OAuth, Single Sign-On policies, and federated services. This is certainly a rabbit hole of possibilities. With the .NET Framework, I would recommend being aware of .NET Identity Framework, Auth0, and Identity Server.

DotNetNuke / SiteCore (CMSs)

.NET does have several Content Management Systems (CMS)s that are very popular and used in many enterprise environments. They allow customizations using ASP.NET. Some CMSs use ASP.NET Web Forms and some use MVC. Make sure you read up on advanced customization to figure out which is the best fit for you.

DotNetNuke
SiteCore

Concurrency / Threading

Concurrency is the process of running many processes at the same time in parallel. There are a lot of challenges to writing multi-threaded concurrent code. Common issues include race conditions, locks, and things getting lost or mixed up. With .NET it includes the ability to create custom threads and there is also support for Asynchronous calls.

Polymorphism

The Oxford definition of polymorphism is “the condition of occurring in several forms”. Polymorphism typically takes a lot of practice to understand. The concept of polymorphism can get complicated because it relates to database design, model class design and the process of using multiple models in place of a single model. Then if you are using a controller you may have to create a custom model binder to process the data that’s being posted to the endpoint. A good example of this is what I did on a stationary website that I created. Instead of creating an endpoint to accept the data necessary to create an image of the product I use polymorphism design to create a single base abstract class that I inherited from and used a custom model binder to map data to the correct class. This resulted in a scalable architecture and significantly reduced code.

Reflection

Reflection isn’t something that I have seen on many projects, it’s actually rather rare. I’ve used reflection in several situations which include writing plugins, reflecting to find classes with custom attributes, and unit testing. Using Reflection in .NET allows a developer to open DLL files, search for private or public methods and then call those methods. This is extremely useful in unit testing private methods.

Integrations

In theory, there could be an infinite amount of applications that a developer could integrate with but it’s important to recognize what common integrations look like. In several environments, I have integrated with Dynamics CRM where sales data was being pushed into CRM through an API. For example, if an order is placed on a website it may be pushed through an integration that places that information into CRM so customer service can be aware of an order. Other types of integrations could include data streaming with platforms like Apache Kafka.

Lexical Parsers

Lexical analysis is the process of converting a sequence of characters into a sequence of tokens. If you were to create an application or library that parsed text as commands or your own programming language you would need to create a tokenizer to process those commands.

Jack Vanlightly – Creating a Simple Tokenizer (Lexer) in C#

Jack wrote a great article about how to create a Logging Query Language (LQL) and a lexical parser to analyze the language.

NuGet Libraries

NuGet is a dependency manager for .NET libraries. Anyone can produce a shareable library (DLL) that can be published to a public NuGet repository and included in a project. There are also private NuGet repositories that companies can use to create and distribute code within the organization. An example of this would be re-sharing a custom logging utility class. Supposed the organization you work for wants every application to use the same exact code. This can be done with a private NuGet repository.

(NuGet Repositories)

Unit Testing

Mastering unit testing is actually more difficult than most developers realize. While in concept it’s rather easy to write unit tests but it’s more than just that. Writing unit-testable code means truly understanding SOLID principles, Dependency Injection, decoupling your code and understanding Test-Driven Development (TDD). Then a developer needs to have strong skillsets with Reflection, using Visual Studio Enterprise with Stubs and Fakes, be very experienced in many unit testing frameworks such as MSTest, xUnit.NET, NUnit, and nSpec (Behavioural Driven Design). Now, this covers a lot of territories and focuses only on using code to do unit tests. A developer also needs to understand build servers, gated check-ins, Continous Integration (CI), TFS (Now called Azure DevOps Server), Jira, along with general testing practices like Integration Testing, Acceptance and Specification.

Windows Internals

Most .NET jobs will be web applications but there are jobs that require high-level knowledge of how Windows actually works under the hood. Offensive Penetration Testers who roll their own code will need to become familiar with hooking into the Windows APIs. A .NET keylogger would need to hook into system events for key presses and this can be done by interacting with the Windows APIs.

Windows Internals Part 2 (Releases: July 16th, 2020)

This is an excellent read if you want to gain more knowledge of how the Windows kernel works.

https://www.amazon.com/Windows-Internals-Part-2-7th/dp/0135462401/ref=sr_1_3?dchild=1&keywords=windows+internals&qid=1584320195&sr=8-3

Udemy Videos

Anyone who knows me, knows I watch a lot of Udemy videos. I’m a big spender on Udemy and have spent thousands of dollars on videos I will soon watch one day. In all seriousness, these are more advanced curriculums but I recommend these videos.