Skip to content

Commit 624b8ac

Browse files
authored
Acrolinx 12/8 (#21886)
* acrolinx * add hard newlines
1 parent b4482a2 commit 624b8ac

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

docs/architecture/modern-web-apps-azure/develop-asp-net-core-mvc-apps.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ app.UseEndpoints(endpoints =>
4444
});
4545
```
4646

47-
In this example, a route named "default" has been added to the routing table. It defines a route template with placeholders for _controller_, _action_, and _id_. The controller and action placeholders have the default specified ("Home" and "Index", respectively), and the id placeholder is optional (by virtue of a "?" applied to it). The convention defined here states that the first part of a request should correspond to the name of the controller, the second part to the action, and then if necessary a third part will represent an id parameter. Conventional routes are typically defined in one place for the application, such as in the Configure method in the Startup class.
47+
In this example, a route named "default" has been added to the routing table. It defines a route template with placeholders for `controller`, `action`, and `id`. The `controller` and `action` placeholders have the default specified (`Home` and `Index`, respectively), and the `id` placeholder is optional (by virtue of a "?" applied to it). The convention defined here states that the first part of a request should correspond to the name of the controller, the second part to the action, and then if necessary a third part will represent an ID parameter. Conventional routes are typically defined in one place for the application, such as in the `Configure` method in the `Startup` class.
4848

4949
Attribute routes are applied to controllers and actions directly, rather than specified globally. This approach has the advantage of making them much more discoverable when you're looking at a particular method, but does mean that routing information is not kept in one place in the application. With attribute routes, you can easily specify multiple routes for a given action, as well as combine routes between controllers and actions. For example:
5050

@@ -83,7 +83,7 @@ In the previous example, the page in question would match a route with an intege
8383
"/Products/123"
8484
```
8585

86-
Once a given request has been matched to a route, but before the action method is called, ASP.NET Core MVC will perform [model binding](/aspnet/core/mvc/models/model-binding) and [model validation](/aspnet/core/mvc/models/validation) on the request. Model binding is responsible for converting incoming HTTP data into the .NET types specified as parameters of the action method to be called. For example, if the action method expects an `int id` parameter, model binding will attempt to provide this parameter from a value provided as part of the request. To do so, model binding looks for values in a posted form, values in the route itself, and query string values. Assuming an id value is found, it will be converted to an integer before being passed into the action method.
86+
Once a given request has been matched to a route, but before the action method is called, ASP.NET Core MVC will perform [model binding](/aspnet/core/mvc/models/model-binding) and [model validation](/aspnet/core/mvc/models/validation) on the request. Model binding is responsible for converting incoming HTTP data into the .NET types specified as parameters of the action method to be called. For example, if the action method expects an `int id` parameter, model binding will attempt to provide this parameter from a value provided as part of the request. To do so, model binding looks for values in a posted form, values in the route itself, and query string values. Assuming an `id` value is found, it will be converted to an integer before being passed into the action method.
8787

8888
After binding the model but before calling the action method, model validation occurs. Model validation uses optional attributes on the model type, and can help ensure that the provided model object conforms to certain data requirements. Certain values may be specified as required, or limited to a certain length or numeric range, etc. If validation attributes are specified but the model does not conform to their requirements, the property ModelState.IsValid will be false, and the set of failing validation rules will be available to send to the client making the request.
8989

@@ -97,7 +97,7 @@ Web API projects should consider using the `[ApiController]` attribute, which ca
9797

9898
For page-based applications, Razor Pages do a great job of keeping controllers from getting too large. Each individual page is given its own files and classes dedicated just to its handler(s). Prior to the introduction of Razor Pages, many view-centric applications would have large controller classes responsible for many different actions and views. These classes would naturally grow to have many responsibilities and dependencies, making them harder to maintain. If you find your view-based controllers are growing too large, consider refactoring them to use Razor Pages, or introducing a pattern like a mediator.
9999

100-
The mediator design pattern is used to reduce coupling between classes while allowing communication between them. In ASP.NET Core MVC applications, this pattern is frequently employed to break up controllers into smaller pieces by using *handlers* to do the work of action methods. The popular [MediatR NuGet package](https://www.nuget.org/packages/MediatR/) is often used to accomplish this. Typically, controllers include many different action methods, each of which may require certain dependencies. The set of all dependencies required by any action must be passed into the controller's constructor. When using Mediatr, the only dependency a controller has is on an instance of the mediator. Each action then uses the mediator instance to send a message, which is processed by a handler. The handler is specific to a single action and thus only needs the dependencies required by that action. An example of a controller using MediatR is shown here:
100+
The mediator design pattern is used to reduce coupling between classes while allowing communication between them. In ASP.NET Core MVC applications, this pattern is frequently employed to break up controllers into smaller pieces by using *handlers* to do the work of action methods. The popular [MediatR NuGet package](https://www.nuget.org/packages/MediatR/) is often used to accomplish this. Typically, controllers include many different action methods, each of which may require certain dependencies. The set of all dependencies required by any action must be passed into the controller's constructor. When using MediatR, the only dependency a controller has is on an instance of the mediator. Each action then uses the mediator instance to send a message, which is processed by a handler. The handler is specific to a single action and thus only needs the dependencies required by that action. An example of a controller using MediatR is shown here:
101101

102102
```csharp
103103
public class OrderController : Controller
@@ -161,15 +161,15 @@ The end result of this approach is for controllers to be much smaller and focuse
161161

162162
> ### References – Mapping Requests to Responses
163163
>
164-
> - **Routing to Controller Actions**
164+
> - **Routing to Controller Actions**\
165165
> <https://docs.microsoft.com/aspnet/core/mvc/controllers/routing>
166-
> - **Model Binding**
166+
> - **Model Binding**\
167167
> <https://docs.microsoft.com/aspnet/core/mvc/models/model-binding>
168-
> - **Model Validation**
168+
> - **Model Validation**\
169169
> <https://docs.microsoft.com/aspnet/core/mvc/models/validation>
170-
> - **Filters**
170+
> - **Filters**\
171171
> <https://docs.microsoft.com/aspnet/core/mvc/controllers/filters>
172-
> - **ApiController Attribute**
172+
> - **ApiController Attribute**\
173173
> <https://docs.microsoft.com/aspnet/core/web-api/>
174174
175175
## Working with dependencies
@@ -383,13 +383,13 @@ You can read more about implementing filters and download a working sample from
383383

384384
> ### References – Structuring applications
385385
>
386-
> - **Areas**
386+
> - **Areas**\
387387
> <https://docs.microsoft.com/aspnet/core/mvc/controllers/areas>
388-
> - **MSDN Magazine – Feature Slices for ASP.NET Core MVC**
388+
> - **MSDN Magazine – Feature Slices for ASP.NET Core MVC**\
389389
> <https://docs.microsoft.com/archive/msdn-magazine/2016/september/asp-net-core-feature-slices-for-asp-net-core-mvc>
390-
> - **Filters**
390+
> - **Filters**\
391391
> <https://docs.microsoft.com/aspnet/core/mvc/controllers/filters>
392-
> - **MSDN Magazine – Real World ASP.NET Core MVC Filters**
392+
> - **MSDN Magazine – Real World ASP.NET Core MVC Filters**\
393393
> <https://docs.microsoft.com/archive/msdn-magazine/2016/august/asp-net-core-real-world-asp-net-core-mvc-filters>
394394
395395
## Security
@@ -439,7 +439,7 @@ You can learn more about [configuring two-factor authentication](/aspnet/core/se
439439

440440
Authentication is the process of determining who is accessing the system. If you're using ASP.NET Core Identity and the configuration methods shown in the previous section, it will automatically configure some authentication defaults in the application. However, you can also configure these defaults manually, or override the ones set by AddIdentity. If you're using Identity, it configures cookie-based authentication as the default *scheme*.
441441

442-
In web-based authentication, there are typically up to 5 actions that may be performed in the course of authenticating a client of a system. These are:
442+
In web-based authentication, there are typically up to five actions that may be performed in the course of authenticating a client of a system. These are:
443443

444444
- Authenticate. Use the information provided by the client to create an identity for them to use within the application.
445445
- Challenge. This action is used to require the client to identify themselves.
@@ -493,13 +493,13 @@ Blazor Server applications can leverage the same authentication features as any
493493

494494
> ### References – Authentication
495495
>
496-
> - **Authentication Actions and Defaults**
496+
> - **Authentication Actions and Defaults**\
497497
> <https://stackoverflow.com/a/52493428>
498-
> - **Authentication and Authorization for SPAs**
498+
> - **Authentication and Authorization for SPAs**\
499499
> <https://docs.microsoft.com/aspnet/core/security/authentication/identity-api-authorization>
500-
> - **ASP.NET Core Blazor Authentication and Authorization**
500+
> - **ASP.NET Core Blazor Authentication and Authorization**\
501501
> <https://docs.microsoft.com/aspnet/core/blazor/security/>
502-
> - **Security: Authentication and Authorization in ASP.NET Web Forms and Blazor**
502+
> - **Security: Authentication and Authorization in ASP.NET Web Forms and Blazor**\
503503
> <https://docs.microsoft.com/dotnet/architecture/blazor-for-web-forms-developers/security-authentication-authorization>
504504
505505
### Authorization
@@ -576,17 +576,17 @@ Be especially careful about "rolling your own" implementation of cryptography, u
576576

577577
> ### References – Security
578578
>
579-
> - **Security Docs Overview**
579+
> - **Security Docs Overview**\
580580
> <https://docs.microsoft.com/aspnet/core/security/>
581-
> - **Enforcing SSL in an ASP.NET Core App**
581+
> - **Enforcing SSL in an ASP.NET Core App**\
582582
> <https://docs.microsoft.com/aspnet/core/security/enforcing-ssl>
583-
> - **Introduction to Identity**
583+
> - **Introduction to Identity**\
584584
> <https://docs.microsoft.com/aspnet/core/security/authentication/identity>
585-
> - **Introduction to Authorization**
585+
> - **Introduction to Authorization**\
586586
> <https://docs.microsoft.com/aspnet/core/security/authorization/introduction>
587-
> - **Authentication and Authorization for API Apps in Azure App Service**
587+
> - **Authentication and Authorization for API Apps in Azure App Service**\
588588
> <https://docs.microsoft.com/azure/app-service-api/app-service-api-authentication>
589-
> - **Identity Server**
589+
> - **Identity Server**\
590590
> <https://github.com/IdentityServer>
591591
592592
## Client communication
@@ -645,9 +645,9 @@ Consider ways in which your applications communicate directly with client applic
645645

646646
> ### References – Client Communication
647647
>
648-
> - **ASP.NET Core SignalR**
648+
> - **ASP.NET Core SignalR**\
649649
> <https://github.com/dotnet/aspnetcore/tree/master/src/SignalR>
650-
> - **WebSocket Manager**
650+
> - **WebSocket Manager**\
651651
> <https://github.com/radu-matei/websocket-manager>
652652
653653
## Domain-driven design – Should you apply it?
@@ -694,7 +694,7 @@ A hybrid approach would be to only use DDD for the transactional or more complex
694694

695695
> ### References – Domain-Driven Design
696696
>
697-
> - **DDD in Plain English (StackOverflow Answer)**
697+
> - **DDD in Plain English (StackOverflow Answer)**\
698698
> <https://stackoverflow.com/questions/1222392/can-someone-explain-domain-driven-design-ddd-in-plain-english-please/1222488#1222488>
699699
700700
## Deployment
@@ -737,13 +737,13 @@ _Learn more about Azure deployment options in [Chapter 10](development-process-f
737737

738738
> ### References – Deployment
739739
>
740-
> - **Hosting and Deployment Overview**
740+
> - **Hosting and Deployment Overview**\
741741
> <https://docs.microsoft.com/aspnet/core/publishing/>
742-
> - **When to use Kestrel with a reverse proxy**
742+
> - **When to use Kestrel with a reverse proxy**\
743743
> <https://docs.microsoft.com/aspnet/core/fundamentals/servers/kestrel#when-to-use-kestrel-with-a-reverse-proxy>
744-
> - **Host ASP.NET Core apps in Docker**
744+
> - **Host ASP.NET Core apps in Docker**\
745745
> <https://docs.microsoft.com/aspnet/core/publishing/docker>
746-
> - **Introducing Azure Application Gateway**
746+
> - **Introducing Azure Application Gateway**\
747747
> <https://docs.microsoft.com/azure/application-gateway/application-gateway-introduction>
748748
749749
>[!div class="step-by-step"]

0 commit comments

Comments
 (0)