ASP.NET Core: A Server-Side Web Application Framework
Sunil Sharma
Turning frowns into clickable smiles! ?? Enterprise UX Analyst on a mission to make software so user-friendly, even your coffee machine will ask for feedback.??
An open-source framework from Microsoft
In this article, I have shared essential information about ASP.NET. You will learn briefly about ASP.NET Core, Web Forums, Web Pages, Web APIs, WebHooks and features of ASP.NET.
ASP.NET is an open-source, server-side web application framework designed for web development to produce dynamic web pages. ASP stands for Active Server Pages. It was developed by Microsoft to allow programmers to build dynamic web sites, applications and services.
ASP.NET Core
- . ASP.NET Core is an open-source and cloud-optimized web framework for developing modern web applications that can be developed and run on Windows, Linux and the Mac. It includes the MVC framework, which now combines the features of MVC and Web API into a single web programming framework.
- ASP.NET Core apps can run on .NET Core or on the full .NET Framework.
- It was architect to provide an optimized development framework for apps that are deployed to the cloud or run on-premises.
- It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions.
- You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac and Linux.
Advantages of ASP.NET Core
- ASP.NET Core has a number of architectural changes that result in a much leaner and modular framework.
- ASP.NET Core is no longer based on System.Web.dll. It is based on a set of granular and well factored NuGet packages.
- This allows you to optimize your app to include just the NuGet packages you need.
- The benefits of a smaller app surface area include tighter security, reduced servicing, improved performance, and decreased costs
Improvements
- Build and run cross-platform ASP.NET apps on Windows, Mac and Linux.
- Built on .NET Core, which supports true side-by-side app versioning.
- New tooling that simplifies modern Web development.
- Single aligned web stack for Web UI and Web APIs.
- Cloud-ready environment-based configuration.
- Built-in support for dependency injection.
- Tag Helpers which makes Razor markup more natural with HTML.
- Ability to host on IIS or self-host in your own process.
Programming Models
- ASP.NET Web Forms — A framework for building modular pages out of components, with UI events being processed server-side.
- ASP.NET MVC — Allows for building web pages using the model–view–controller design pattern.
- ASP.NET Web Pages — A lightweight syntax for adding dynamic code and data access directly inside HTML markup.
- ASP.NET Web API — A framework for building Web APIs on top of the .NET Framework.
- ASP.NET WebHooks — Implements the WebHook pattern for subscribing to and publishing events via HTTP.
- SignalR — A real-time communications framework for bi-directional communication between client and server.
Other ASP.NET Extensions
- ASP.NET Handler — Components that implement the System.Web. IHttpHandler interface. Unlike ASP.NET Pages, they have no HTML-markup file, no events and other supporting. All they have is a code-file (written in any .NET-compatible language) that writes some data to the server HTTP response. HTTP handlers are similar to ISAPI extensions.
- ASP.NET AJAX — An extension with both client-side as well as server-side components for writing ASP.NET pages that incorporate Ajax functionality.
- ASP.NET Dynamic Data — A scaffolding extension to build data-driven web applications.
The .NET Core Platform
.NET Core Platform contains the following main parts:-
- .NET Runtime ? It provides a type system, assembly loading, a garbage collector, native interoperability and other basic services.
- Fundamental Libraries ? A set of framework libraries, which provide primitive data types, app composition types and fundamental utilities.
- SDK & Compiler ? A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.
- ‘dotnet’ app host ? It is used to launch .NET Core apps. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way.
Brief History
- ASP.NET was released in 2002 as a successor to Classic ASP.
- ASP.NET pages have the extension .aspx and are normally written in C# (C sharp).
- On Nov 2005, ASP.NET 2.0 was released, together with Visual Studio 2005 and Visual Web Developer Express and SQL Server 2005.
- On Nov 2006, ASP.NET 3.0 was released.
- On April 2010, ASP.NET 4.0 was released, Parallel extensions and other .NET Framework 4 features.
- On April 2019, ASP.NET 4.8 was released.
- On Nov 2018, ASP.NET 5 was expected to be an important redesign of ASP.NET.
- However, the development of ASP.NET 5 was stopped in favour of ASP.NET Core.
Features Of ASP.NET
1. Cross-platform & container support
With the introduction of .NET Core, you can now create ASP.NET applications and deploy them to Windows, Linux, and macOS. Microsoft and the community have put a huge effort into making Linux a first-class citizen for running ASP.NET.
2. High performance
Some say that performance is a critical feature of your software. The technology that powered the ASP.NET integrated pipeline and IIS was roughly 15 years old. It did everything and carried a lot of baggage with it. The new Kestrel webserver was redesigned from the ground up to take advantage of asynchronous programming models, be much more lightweight, and fast.
3. Asynchronous via async/await
ASP.NET has excellent support for utilizing asynchronous programming patterns. Asynchronous is now implemented in all common .NET Framework classes and most third-party libraries. Most modern applications spend most of their time and CPU cycles waiting for database queries, web service calls, and other I/O operations to complete.
4. Unified MVC & Web API frameworks
With ASP.NET Core, MVC and Web API have been merged together. There was always a lot of overlap with the two frameworks. MVC could always return JSON data instead of HTML. Combining them was a good move and simplifies development.
5. Multiple environments and development mode
It allows you to easily differentiate parts of your code for their behaviour in development, staging, production, etc. There was no standard way to do this before ASP.NET Core.
For example, it is used within your Startup.cs file to help configure your application. In this case, whether or not we want to show a more detailed exception page for development only.
6. Dependency Injection
One of the great new features of ASP.NET Core is built-in dependency injection. It is heavily used within ASP.NET MVC itself. It is the preferred way that things like logging contexts, database contexts, and other things are passed into your MVC controllers.
7. WebSockets & SignalR
ASP.NET has first-class support for WebSockets. This can be used to persist long-running connections and communicate back and forth with the browser. SignalR is a full framework that is also available that makes it easy to handle common scenarios.
8. Cross-Site Request Forgery (CSRF) Protection
Security is important. It is also one of those things that can be a lot of work to prevent certain types of attacks. CSRF is in referencing to hijacking users authenticated session to perform an action that they did not initiate.
9. “Self-hosted” Web Applications
Sometimes you need to make a web application that will be deployed on to a desktop and not a server running IIS. Our free ASP.NET profiler, Prefix, is a perfect example of this. Its front end is all HTML that is loaded from an ASP.NET application running as a Windows Service.
You can create a self-hosted ASP.NET web application in several different ways. In .NET 4.5 you could accomplish it by using Owin, Nancy, or WCF. For Prefix, we use ASP.NET Web API with Owin.
10. Action Filters
One of the great features of ASP.NET is the support for extensible filters. This allows you to implement functionality that can be applied to an entire controller or action without modifying the action itself.
Filters are used to specify caching, error handling, authorization, or any custom logic you would like to implement.
11. Extensible Output Caching
This feature allows ASP.NET to cache the output generated by a page and serve this cached content for future requests. It stores the data that is not updated frequently and outputs that specific data from a cached location.
12. Globalization and Localization
ASP.NET makes it easy to localize dates, numbers, and the text within your web application. If you want your application to be used across the globe,
localization will be very important to you.
13. Swagger OpenAPI
If you are creating API applications, you want to make sure you are using Swagger. It makes it easy to document and test your APIs.
ASP.NET has historically provided built-in functionality that is pretty similar for SOAP web services created with WCF. If you are using Web API or MVC for RESTful APIs, you definitely want to use Swagger.
Applications:-
- ASP.NET was designed to build applications which could run on the Windows platform.
- Android, iOS, Linux, Mac, and Windows applications
- Forms-based applications
- Web-based applications
- Web services
- Rapid development using a rich library of controls that encapsulate HTML markup. (Web Forms)
- Full control over HTML markup, code and markup separated, and easy to write tests. The best choice for mobile and single-page applications (SPA). (MVC)
- HTML markup and your code together in the same file. (Web Pages)
Note:- ASP.NET Core merges of ASP.NET Web Pages, ASP.NET Web APIs, ASP.NET MVC into one application framework.