Can some one confirm me that asp.net web api action filters are singleton/instance based by default? In asp.net core, I observed that it has one instance by default and the method is as per request-based. I am not sure on wweb.api action filters. Sorry if this question sounds silly.
using System.Web.Http.Filters;
namespace SampleApp.Attributes
{
public class CustomAttribute: Attribute, IActionFilter
{
public CustomAttribute()
{
// resolves dependencies here
}
public Task<HttpResponseMessage> ExecuteActionFilterAsync(HttpActionContext actionContext,
CancellationToken cancellationToken, Func<Task<HttpResponseMessage>> continuation)
{
// some code goes here with some update operations in sql server stored procedure level
}
}
}
As it states in the Microsoft documentation for filters (https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-6.0#thread-safety):
If you're registering the filter type (rather than an instance), the framework will indeed create a new instance of the filter per request.