In the last tutorial we covered Built-In Tag Helpers in ASP.NET Core. Now we will learn to create Custom Tag Helper for transforming the html elements with C# codes. We will take a lot of examples so make sure to go through each of the sections on this tutorial.
(more…)
Many of the ASP.NET Core Tag Helpers comes pre-built in the framework and are represented as asp-* attributes. They perform tasks like enhancing forms, validation messages, designing layouts and so on. In this section I am going to discuss about the built in Tag Helpers for Form, Input, Select, Label, Anchor, Text Area elements, CSS, JS and Cache.
(more…)
What are Tag Helpers in ASP.NET Core ? Tag Helpers are reusable components in ASP.NET Core. They are used to perform "defined transformations on HTML elements" from C# codes before being rendered on the views. With Tag Helpers we can enable server-side code to participate in creating and rendering the HTML elements. The most commonly used tag helpers are asp-controller and asp-action which assigns the controller & action for generating the URL. Example: <a asp-controller="Shop" asp-action="Clothes">Buy Clothes</a>
will generate HTML <a href"/Shop/Clothes">Buy Clothes</a>
.
On my previous tutorial called How to Create Web APIs in ASP.NET Core [RESTful pattern] I created a Web API. Now I will call this API (i.e. consume the API) in another project known as client.
(more…)
Creating Web APIs in ASP.NET Core is very straightforward. You create controllers that have 3 things:
[Route("someUrl/[controller]")]
.The controller of a Web API looks like:
(more…)
The concept of Routing is very vast and I have covered it in 6 tutorials which are:
So make sure you cover each of these one by one.
ASP.NET Core Areas represent a functional segment of the application. It can be administration, billing, sales, etc. If our application becomes very large then it will have many controllers, Models & Views. We can create multiple Areas to distribute the application files into them. This will help us to manage our application in a better way.
(more…)
The concept of Routing is very vast and I have covered it in 6 tutorials which are:
So make sure you cover each of these one by one.
ASP.NET Core Attribute Routing adds routes by applying C# attributes on the controller and actions methods. Note that if convention routes are also present then we can override them by adding attribute routes. This is because DOT NET gives preference to attribute routes.
(more…)
ASP.NET Core Routing Constraints restricts route matching to a set of URLs. This is done by applying different types of constraints or rules in the route patterns.
Let’s start understanding this topic by creating a simple example project.
(more…)
What is ASP.NET Core routing? Routing is used to create URL patterns for a web app. These route patterns match the incoming HTTP requests and dispatches these requests to the endpoints in the app. Endpoints are those units that are responsible for handling these requests. Most commonly endpoints are the Controllers in an ASP.NET Core MVC app.
In the Program.cs class we can define one or more ASP.NET Core Routes to perform the following tasks:
(more…)