Ich habe verschiedene Dinge ausprobiert, wie zum Beispiel das Einfügen eines ActionContextAccessor wie unten und dessen Verwendung, aber es gibt immer null zurück.
Code: Select all
builder.Services.AddSingleton();
var ctx = HttpContext.RequestServices.GetRequiredService()
< pre class="lang-cs Prettyprint-override">
Code: Select all
var actionContext = new ActionContext(HttpContext, HttpContext.GetRouteData(), new ActionDescriptor());
// then when I do something like this I get nothing
var httpAttributes = actionContext.ActionDescriptor.GetAttributes().GetAwaiter().GetResult();
string entity = (actionContext.ActionDescriptor?.GetAttributes().GetAwaiter().GetResult()).FirstOrDefault()?.Name;