C# 如何从自定义中间件dotnet核心获取custrom属性
我正在尝试创建一个自定义缓存中间件,它具有一个自定义属性,指定应该缓存哪些操作 现在我的问题是,从中间件的角度来看,如何知道从可缓存操作接收到请求 这是我的中间件:C# 如何从自定义中间件dotnet核心获取custrom属性,c#,.net-core,.net-core-3.1,C#,.net Core,.net Core 3.1,我正在尝试创建一个自定义缓存中间件,它具有一个自定义属性,指定应该缓存哪些操作 现在我的问题是,从中间件的角度来看,如何知道从可缓存操作接收到请求 这是我的中间件: public class CacheResponseMiddleware { private readonly RequestDelegate _next; private readonly IDatabaseContext database; public CacheResponseMiddleware(
public class CacheResponseMiddleware
{
private readonly RequestDelegate _next;
private readonly IDatabaseContext database;
public CacheResponseMiddleware(RequestDelegate next, IDatabaseContext database)
{
_next = next;
this.database = database;
}
public async Task InvokeAsync(HttpContext context)
{
// check if this request should be cached or not
}
}
这是我的自定义属性:
[AttributeUsage(AttributeTargets.Method)]
public class RetryCachableAttribute : Attribute
{
public RetryCachableAttribute()
{
}
}