action-filter Questions
5
Solved
Taking a simple action filter, which checks if the user is logged in and retrieves their user ID.
public class LoginFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionE...
Elenaelenchus asked 9/8, 2016 at 13:34
5
Solved
I use constructor-based dependency injection everywhere in my ASP.NET CORE application and I also need to resolve dependencies in my action filters:
public class MyAttribute : ActionFilterAttribut...
Lonne asked 31/8, 2016 at 18:11
5
Solved
Is it possible to skip the whole action method execution and return a specific ActionResult when a certain condition is met in OnActionExecuting?
Screech asked 23/3, 2012 at 9:59
5
Solved
I am using latest web api.
I do annotate some controllers with 3 different filter attributes.
1 [Authorize]
2 [RessourceOwnerAttribute derived from AuthorizationFilterAttribute]
3 [InvalidModelSt...
Breastsummer asked 7/2, 2014 at 13:0
3
I want to write a custom filter which will check whether a user is logged in to my site, and redirect them back to the login page if they aren't.
I want the filter to apply automatically to the pa...
Ovi asked 29/11, 2018 at 12:14
3
Solved
Can I pass an argument from Action Filter to a controller and specifically through the parameters (in ASP.NET Core) ?
For example:
public class CategoryController : Controller
{
[HttpGet]
[Serv...
Apocryphal asked 2/1, 2019 at 20:3
3
Solved
Need some pointers for this. Found this and this, but I'm still kind a confused.
I just want to mock ActionExecutedContext, pass it, let filter to work a bit and check result.
Any help?
Source ...
Jailer asked 29/6, 2009 at 11:14
3
Solved
ASP.NET Core's ActionFilterAttribute has these:
public virtual void OnActionExecuting(ActionExecutingContext context);
public virtual void OnActionExecuted(ActionExecutedContext context);
public v...
Kapor asked 15/5, 2017 at 12:43
1
Solved
I'm trying to implement an IAsyncActionFilter in order to redirect to a Maintenance page if the application is set OnMaintenance in the appsettings.json.
I firstly implemented the ActionFilter as f...
Ouzel asked 27/12, 2020 at 18:43
5
Solved
I use a custom AuthorizationFilter like the followings:
public class ActionAuthorizeAttribute : AuthorizeAttribute {
protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext) ...
Reisinger asked 2/4, 2012 at 12:31
6
Best way to abort/cancel action from ActionFilter
I've got this ActionFilter, and it's suppose to end the connection immediately and return a 401 Unauthroized:
public class SignInRequired : Actio...
Cassandry asked 3/3, 2011 at 20:55
1
Solved
I have created the following Custom ActionFilter, when I try to access the Model in the following code, it is null:
public class CustomPermissionCheckAttribute : ActionFilterAttribute
{
public ov...
Genaro asked 9/5, 2020 at 9:7
3
Solved
According to this documentation for ASP.NET Filters filters run in the following order:
Authorization filters
Action filters
Response filters
Exception filters
The within each filter type there...
Heidi asked 17/8, 2015 at 11:56
3
Solved
I want to return a json object from the wep api actionfilter.
How can I achieve this?
I can return the object from action but I need to return some data from the actionfilter on some condition.
T...
Mendie asked 26/6, 2013 at 10:25
1
Solved
I could inject CancellationToken into ASP.NET Core action method, but I would instead prefer to work with it using action filter. How to get access to cancellation token while implementing IAsyncAc...
Give asked 3/10, 2019 at 5:3
5
Solved
For multilingual ASP.NET MVC 3 web application, I am determining the Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture on the controller factory as follows:
public clas...
Helmut asked 22/11, 2011 at 12:5
5
Solved
I'm working with nopCommerce and I need to add in my only Action Filter, however, I don't want to modify the core controllers to avoid my code being overwritten when a new update is released.
I've...
Splenomegaly asked 9/1, 2012 at 9:25
2
Solved
Here I want to return from the custom action filter without executing the controller action method in asp.net core WEB API.
Below is my requirement with sample code.
public override async Task On...
Trivia asked 26/2, 2019 at 9:57
2
Solved
I am working with asp.net WebAPI and I need to create a custom ActionFilter that does a quick check to see if the user requesting the URI should actually be able to get data back.
They have alrea...
Bromeosin asked 14/12, 2012 at 18:10
4
Solved
I have added Output Caching to a couple of actions in my app for some easy performance boosts. However, these actions also need to increment a counter after each request (it's a views counter) by h...
Palstave asked 12/6, 2012 at 3:52
2
Solved
I'm trying to audit my action events on the controller. I want to keep track of authenticated user's name, his IP address, and controller action being called.
My filter code:
public class AuditAt...
Dodecanese asked 6/12, 2016 at 9:58
1
Solved
I am not getting my ExceptionHandling hit when I have the CompressFilter on the action and their is an error. No response is returned on the request. If I remove the Compress filter then it returns...
Unmentionable asked 20/10, 2018 at 15:38
2
I have my authentication logic in a class, derived from System.Web.Http.AuthorizeAttribute (overridden OnAuthorization method). I make a call to a DB from that method and I want that call to be asy...
Rondure asked 19/10, 2012 at 17:3
4
Solved
I'm trying to resolve the dependencies of my custom AuthorizeAttribute which I use to decorate my API controllers in an MVC4 app. Problem is that I keep getting a NullReferenceException on the serv...
Soutache asked 25/4, 2014 at 19:15
4
Solved
I am writing an Authorize filter attribute adn I'm having trouble figuring out how to get the current url as a string so I can pass it as a parameter to the LogOn action. The goal is that if a user...
Coney asked 25/5, 2012 at 21:25
1 Next >
© 2022 - 2024 — McMap. All rights reserved.