.Net 2 Flashcards

1
Q

Do you need to register DeveloperExceptionPageMiddleware in .net 6?

A

No. It’s registered automatically when ASPNETCORE_ENVIRONMENT = Development

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to add a custom filter for

A

Just register singleton realization of IDeveloperPageExceptionFilter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What app.UseHttpsRedirection() does?

A

It registers HttpsRedirectionMiddleware, that redirects all non-HTTPS requests to HTTPS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What builder.Services.AddRazorPages() does?

A

Performs the next call
services
.AddMvcCore()
.AddAuthorization()
.AddDataAnnotations()
.AddRazorPages()
.AddCacheTagHelper();

AddMvcCore() creates MvcCoreBuilder
So next call of AddRazorPages is extension method on IMvcCoreBuilder.

So the call registers everything razor pages need in order to work with MVC.

IMvcCoreBuilder.AddRazorPages() adds AddRazorViewEngine with all required services and options, e.g. RazorViewEngineOptions, RazorPagesOptions, caches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What app.MapRazorPages() does?

A

It adds data source for razor pages (PageActionEndpointDataSource) to IEndpointRouteBuilder.DataSources.

IEndpointRouteBuilder.DataSources is used in EndpointRoutingMiddleware (UseRouting) for matching requests to endpoints.

As a result, all razor pages in ApplicationParts will have an endpoint now. Your project is default ApplicationPart, if you have some external project you have to register it as ApplicationPart. For example Microsoft.AspNetCore.Identity.UI do it for default identity pages like login, register, etc.

ApplicationPart of a project is called AssemblyPart

How well did you know this?
1
Not at all
2
3
4
5
Perfectly