2

I recently started migrating my app from Web.Api .NET standard to .Net Core.

First of all are all the steps of the Web Api pipeline still there?

When i say all the steps i mean : Web api pipeline Poster

In terms of usage i can see the filters are applied through the

 [ServiceFilter(typeof(NameOfAttribute))]

But in a variety of articles like this one : https://andrewlock.net/asp-net-core-in-action-filters/

i can see different kind of filters like resource and results filters.

Also i cannot see the usage of Delegating Handlers.

Where should we integrate the functionality of the previous pipeline with the new standards?

Thanks

kostas.kapasakis
  • 920
  • 1
  • 11
  • 26

1 Answers1

3

Since classic Asp.Net and Asp.Net core are cognate technologies there are many common concepts in a request processing, but there are some differences and most likely you will have to rewrite some stuff in your project.

As you noted there are new filters. They allow to handle request in more granular approach. You can use filters as you did it before just by decorating actions and controllers:

[SomeFilter]
public IActionResult SomeAction(){...}

And (as before in classic Asp.Net) you can't use dependency injection through the filter constructor. Filters applied like that behave like a singleton. One instance is used for all requests.

ServiceFilterAttribute and TypeFilterAttribute allow to use the dependency injection through the filter constructor. Optionally filters applied like that can behave like singletons or can be created every time (with dependency injection) for every request. You can adjust it by using IsReusable property. Read more about filter here.

There are no more Delegating Handlers. Instead of you can create a custom middleware. You can see an example here.

AlbertK
  • 11,841
  • 5
  • 40
  • 36