Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
58 views

Getting an unknown Type at runtime in a Web API action filter

I want to be able to change an object result value within an action filter without using reflection. I am able to get this to work fine (as provided in the code below) if I provide the type (Person) ...
MVCKarl's user avatar
  • 1,295
1 vote
1 answer
955 views

How to log requests and responses in .NET Core APIs?

I want to keep the Log of Requests and Responses in certain API endpoints in .NET Core APIs. For that purpose, I have created an ActionFilter in ASP.NET Core. However, in my code, the code can Log the ...
Simant's user avatar
  • 3,952
0 votes
0 answers
19 views

How to make the 2 sheets work with filter action?

I have 2 dashboards with city and city group filters. In the 1st dashboard when I click on a specific city name it has to redirect to the 2nd dashboard and the dashboard needs to filter according to ...
June's user avatar
  • 1
1 vote
1 answer
34 views

Sitecore10 MVC AuthorizationFilterAttribute OnAuthorization method is not firing

Authorization filter attribute is not firing public class AuthenticationRequiredAttribute : System.Web.Http.Filters.AuthorizationFilterAttribute { public override bool AllowMultiple ...
Himanshu Agarwal's user avatar
1 vote
2 answers
177 views

HttpResponseBody manipulation or replacement in ActionFilterAttribute or IActionFilter

As simple as it is I am trying to replace my context.HttpContext.Response.Body with another stream. I have come so far that I can hijack the stream but replacing it doesnt work. Now I am using the ...
codingjoe's user avatar
  • 790
1 vote
0 answers
81 views

ActionFilter in high requests is slow?

I have an application with high incoming requests in each millisecond. for measuring the response time of requests, I use ActionFilter. but it seems to me, it takes a lot time to get to EndRequest in ...
Programmer's user avatar
2 votes
1 answer
637 views

Custom result filter vs InvalidModelStateResponseFactory in ASP.NET Core 6.0

I can use a custom result filter inherited by IResultFilter to return response in case of a model-validation failure: public class FailedValidationResultFilter : IResultFilter { public void ...
phougatv's user avatar
  • 998
0 votes
0 answers
34 views

.net core MemoryCache strange behavior

I have a singleton ActionFilter and I want to store data in cache. What I did: Program.cs builder.Services.AddSingleton<MyActionFilter>(); builder.Services.AddMemoryCache(); ActionFilter public ...
Jamil's user avatar
  • 910
0 votes
3 answers
1k views

Support multiple authorization filters for one action in ASP.NET Core

We have an IAuthorizationFilter and we can use it to authorize requests. But there is one problem with it. I have to support multiple authorization filters, e.g.: BearerTokenAuthorizationFilter ...
Szyszka947's user avatar
0 votes
0 answers
35 views

ActionFilter compatible with both Mvc and WebAPI

I created an ASP .NET WebApi application that has a web service part which I wrote myself, and a web site part that came by default after creating the project and which provides a dynamically ...
Virus721's user avatar
  • 8,223
1 vote
1 answer
805 views

Why does my custom filter not being called with servicefilter or typefilter in .NET Core 6.0?

I have a problem with the following code. I tried to implement a custom action filter with dependency injection to my constructor. I followed the exact way according to this tutorial, but my custom ...
ısmaıl sahan's user avatar
0 votes
0 answers
59 views

how to introduce a new version / different logic for ActionFilter in c#

I am trying to change the way our existing c# application handles security. The end result is that a we will use a new "user" object that looks different from the current user object we ...
dot's user avatar
  • 15.5k
0 votes
0 answers
372 views

Handling expired oAuth token in asp.net mvc

I created a custom filter class which inherit ActionFilterAttribute the method looks like below public override void OnActionExecuting(HttpActionContext actionContext) { //my custom code } and my ...
Ibrahim shaikh's user avatar
0 votes
1 answer
719 views

How to read RequestBody by PipeReader and return start position of stream to zero (Net core 6)

I need access to RequestBody inside OnActionExecuting or OnActionExecuted filter, but I can not found concrete example how to use PipeReader to read full request body stream and return stream position ...
user avatar
1 vote
1 answer
2k views

Controller timeout on dotnet core

I have an web api on dotnet core 3.1 and I want to set different timeout specific controller action.I try to create an actionfilter something like below public class TimeOutAttribute : ...
Yusuf Kayikci's user avatar
0 votes
0 answers
540 views

How to validate the request is coming from the same domain using ASP.Net c# except UrlReferer as this can be faked

How to validate the request is coming from the same domain using ASP.Net c# except UrlReferer as this can be faked. I want this validation in Custom Action filter for a specific API controller.
Hassnain Balghari's user avatar
0 votes
1 answer
78 views

How to create ActionFilter in Javascript?

I understand that there is a concept of Action Filters in languages like C# using ASP.NET. I would like to have this kind of pre-processing functionality in my class methods, using Javascript. Is this ...
sayandcode's user avatar
  • 2,934
0 votes
2 answers
5k views

Why I'm getting Unable to cast object of type 'Microsoft.AspNetCore.Mvc.ViewResult' to type 'Microsoft.AspNetCore.Mvc.ContentResult'?

I'm following this tutorial on Linkedin Tutorial , and in this video the presenter shows how to use ActionFilter , however , when I execute this application Unable to cast object of type 'Microsoft....
Dotnet_Developer10's user avatar
0 votes
1 answer
3k views

What is the .NET Core equivalent of IAuthenticationFilter?

How can authentication be done in .NET Core as it was done using IAuthenticationFilter? public class CustomAuthenticationFilter : ActionFilterAttribute, IAuthenticationFilter { void ...
Dinesh's user avatar
  • 1
0 votes
1 answer
1k views

C# - Custom ActionFilter pass in configuration variables

I have a custom action filter that takes in a property but I need the property to come from my appsettings.json file. I pass my configuration into the controller, but when I try to pass in the "...
Jeremy P's user avatar
  • 1,407
4 votes
1 answer
2k views

ASP.NET Core 6 ExceptionMiddleware and Validations

In ASP.NET Core 6, I have a custom middleware that handles exceptions returning a specific structure: services.AddControllers(options => options.Filters.Add(typeof(...
Ian Vink's user avatar
  • 68.4k
0 votes
0 answers
106 views

ASP.NET MVC Action calls another action but doesn't trigger OnActionExecuting for the second one

I have a custom ActionFilterAttributes in my solution, and using OnActionExecuting to do some logs. However, the problem occurs because I want to trace the entire path taken during an action, and if ...
props's user avatar
  • 105
2 votes
2 answers
2k views

MinimalAPI Action filter never get executed

I am working on a minimal API and I am trying to make an actionfilter for authentication works with it. I tried to add my action filter directly on the endpoint registration likeso: app.MapGet("/...
user3907939's user avatar
0 votes
1 answer
489 views

Tableau Dashboard Actions Filter - Apply all filters and data element selections to a second worksheet

I have a worksheet (let's call it Worksheet A) with a line graph that tracks payments for products over time with Year / Quarter as the X axis. There are four product types, placed on Color, so there ...
D_man's user avatar
  • 113
0 votes
1 answer
3k views

.Net 6 How detect action filter is on Controller or Action method

I have an action filter like this: public class TestAttribute : IAsyncActionFilter, IOrderedFilter { public async Task OnActionExecutionAsync(ActionExecutingContext context, ...
sa-es-ir's user avatar
  • 4,828
2 votes
1 answer
882 views

Is it possible to redirect to another action using a custom action filter?

I'm not familiar with ASP.NET Core actions' custom filter attribute. I need to redirect to another action in case some data does not exist using a custom method filter. Here is my attempt: [...
MedoofromEgypt's user avatar
0 votes
1 answer
433 views

Change Authorization and Authentication Order Net.Core 3.1

We have an Identity Server 4 to authorize users and custom authorization in API project. I want to set both of these authorizations together, but first check Identity Server 4 and then my custom ...
Ali.Ahmadi's user avatar
0 votes
1 answer
5k views

ASP.NET Core 5 add action filter with parameter

Trying to add an authentication filter to an ASP.NET Core 5 MVC action method and pass a parameter. However I'm unable to find a way to do this. This is the action filter code: public class ...
Abdul Ali's user avatar
  • 1,927
0 votes
0 answers
69 views

C# Inject Javascript into View with JsonResult

I have a Controller Action which returns a JsonResult instead of a View. Depending on whether or not the method completed successfully, I need to add and execute a Javascript. I've added an ...
M. Chris's user avatar
  • 171
0 votes
1 answer
1k views

Catch Exception from ActionFilter in ExceptionFilter in .net core c#

I have a ActionFilter.cs which throws exception in OnActionExecuting method as follows if (!token.IsCancellationRequested) { token.Register(() => { throw new OperationCanceledException(token); }...
RISHU GUPTA's user avatar
0 votes
0 answers
347 views

How to release memory and CPU usage from a Cancelled thread?

I have used CancellationToken in ActionFilter to cancel a task if user closes the tab after GET request (as this is heavy task i.e. takes time 20 sec and memory also). if (!token....
RISHU GUPTA's user avatar
-1 votes
1 answer
2k views

How to Log HTTP requests and responses inside OnActionExecutionAsync ASP .Net Core

How can I Log HTTP requests and responses inside OnActionExecutionAsync?
Hayk Beroyan's user avatar
1 vote
0 answers
406 views

Custom action filter attribute performs poorly when compared to RequestSizeLimit attribute

I have a use-case when I need to limit the allowed request size for the file upload WebAPI endpoint. Normally I would use the in-built attribute RequestSizeLimit: [HttpPost] [RequestSizeLimit(...
Alex's user avatar
  • 5,157
-1 votes
2 answers
738 views

Null Models with default arguments need to be instantiated as such

I have the following asp.net WebApi2 route using .NET 4.6 that illustrates the problem I am having: [Route("books/{id}")] [HttpGet] public JsonResponse GetBooks(string id, [FromUri]...
markf78's user avatar
  • 627
0 votes
1 answer
1k views

Catching errors from services in Exception Filter

I've created a service that's used throughout my aspnet project that retrieves and validates a header among other things. Issue is that the Exception Filter is not able to catch the errors that are ...
NotFound's user avatar
  • 5,845
0 votes
1 answer
192 views

Change Request in ActionFilter By Property attributes

I am coding a .Net core API that serves administrators and employees. These people see the same interface. The only difference is that the manager can view the profile of other employees. The employee ...
Ahmet Umut Aydin's user avatar
0 votes
1 answer
763 views

ActionFilter is not working with AJAX call

I have an AJAX call for a DataTable that is calling a method in my controller with a return type of JsonResult. If the user's session has expired, I get a JSON error alert and the site hangs. I am ...
Timothy Sutton's user avatar
1 vote
0 answers
57 views

Custom permalink load template

I created functions below to customize the permalink of a specific category. Everything is working right! When accessing the post with this permalink example.com.br/negocios/name-post everything is ok....
Renan Bessa's user avatar
0 votes
1 answer
1k views

Asp.Net MVC ActionFilter to validate query params for xss

I had the situation where I wanted to do query parameter (not form parameter) xss handling* for all of my MVC flows (and hence ActionFilter was ideal); but even on Microsoft docs I couldn't find a ...
gawkface's user avatar
  • 2,274
1 vote
2 answers
1k views

Why is there no access to context.Result.StatusCode in Action and Result filters?

I'm trying to write an action or result filter that automatically does something if the status code is >= 400. The ActionExecutedContext.Result property looks like it should provide access to the ...
db2's user avatar
  • 306
-1 votes
1 answer
723 views

The binary operator Equal is not defined for the types 'System.Int32' and 'System.String' in Action filter Asp.net core 5

I'm working on an Asp.net core 5 project. I created an action filter that would apply with HttPost actions especially with create, this filter will check if an object already exist in the database ...
JOCKH's user avatar
  • 399
2 votes
1 answer
2k views

How to pass parameters to a generic Action filter

I'm working on an Asp.net core 5 project targeted .Net 5, I try to create an Action filter that will receive a property name, and he will recieve a TEntity generic type (represent the table to select ...
JOCKH's user avatar
  • 399
0 votes
0 answers
148 views

How to determine if a certain model is bound from request body or from route or from query parameters, etc. in ASP.NET Core

I am using ASP.NET Core 5.0 with .NET 5.0 on Windows. One thing I need to do is from a ActionFilter to determine if a particular action argument is bound using request body. Is there a way to inspect ...
imgen's user avatar
  • 2,983
0 votes
0 answers
201 views

How to move custom authorization attribute policy implementation logic to startup?

I have implemented a custom [Authorize] attribute in a ASP.NET MVC Core 3.1 app. The main reason I have a custom one is because the app uses a lot of AJAX and I couldn't figure out how to get it to ...
Lukas's user avatar
  • 2,141
0 votes
1 answer
486 views

How To Use ActionFilters in OwinSelfHost

I use microsoft.owin to self host WebApi in ConsoleApplication but the ActionFilters Doesnt Fire in app . here is my actionFilter : public class FilterA : Attribute, IActionFilter { public void ...
Sign's user avatar
  • 113
0 votes
1 answer
1k views

ASPNET core. Exclude global filter for a specific Action

I have a global ActionFilter that checks the status of Boolean value and returns to Disabled page if False public void OnActionExecuting(ActionExecutingContext context) { var ...
MADMAX's user avatar
  • 160
0 votes
0 answers
752 views

How can I insert a log entry when the user logs in the system using Serilog in a .NET Core 3 with Angular application

We are using Serilog in a .NET Core 3 application with Angular 9 and we log POST,PUT,DELETE methods using an action filter setup in a BaseController class using attributes like the following [...
Tony's user avatar
  • 37
0 votes
0 answers
1k views

PostgresException: 23503: update or delete on table violates foreign key constraint

When I want to insert to log table in OnActionExecuted (action filter) after endpoint executed I get below error: Npgsql.PostgresException (0x80004005): 23503: update or delete on table "Roles&...
John Lenon's user avatar
2 votes
0 answers
154 views

How to apply IActionFilter only to a single controller?

I want to handle exceptions for one of my Api controllers in a certain manner. I've found this sample: public class HttpResponseExceptionFilter : IActionFilter, IOrderedFilter { public int Order { ...
Yoda's user avatar
  • 18k
0 votes
1 answer
268 views

Couldn't avoid NullReferenceException in Action Filter (ASP.NET Core)

I'm writing an action filter for setting LastAccessDate user property. On retrieving user's record from DB, i'm getting NullReferenceException. How to get rid of this exception? Here is my Action ...
User_890's user avatar
  • 179

1
2 3 4 5
13