Questions tagged [onactionexecuting]

ASP.NET MVC Controller.OnActionExecuting Method. Called before the action method is invoked.

ASP.NET MVC Controller.OnActionExecuting Method.

Called before the action method is invoked.

Remarks: If this method is overridden in a derived Controller class, it will be called for every action method in the class. For more flexibility, derive a class from ActionFilterAttribute and override this method in the derived ActionFilterAttribute class.

42 questions
1
vote
0 answers

WEB API Catch exception in actionfilterattribute and re throw in actionmethod. Exception thrown in specific catch block should be caught

namespace ABC.Web.API.App_Start { public class CustomFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting(HttpActionContext actionContext) { SecureResponse response = new…
Developer
  • 11
  • 2
1
vote
2 answers

Customer ActionFilterAttribute OnActionExecuting override never called

I'm using MVC 4. I code this customer attribute that inherits from System.Web.Mvc.ActionFilterAttribute public class AuthorizedAttribute : ActionFilterAttribute { public AccessLevel Threshold { get; set; } public AuthorizedAttribute() …
MrGrabazu
  • 95
  • 1
  • 9
1
vote
0 answers

RedirectResult and RedirectToRouteResult not working inside OnActionExecuting

RedirectResult and RedirectToRouteResult not working inside OnActionExecuting if address specified as localhost(/Account/LogIn), if i specify url as http://google.com working properly.I wrote a BaseConfig class for administer session.That…
1
vote
1 answer

How to get hash part of a History.js URL from in MVC Controller's OnActionExecuting

I have a custom jQuery control that uses History.js to change browserstate and load child panels via Ajax. In HTML 5 browsers the URl is changed completely so a page refresh works (loads the current panel). However in IE9, and older, the state is…
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
1
vote
0 answers

Excel VBA Cannot call function with onaction

I write a script for a ok button in a userform to create a delete button on the sheet to delete the whole line. The problem is that when I click the delete button, it cannot call the function I assigned with onaction parameter. Private Sub…
1
vote
4 answers

OnActionExecuting fires multiple times

I'm not sure if this is the correct way to go about the problem I need to solve... however in an OnActionExecuting action filter that I have created, I set a cookie with various values. One of these values is used to determine whether the user is…
cw_dev
  • 465
  • 1
  • 12
  • 27
1
vote
2 answers

C# Getting inherited variables (initialized in "OnActionExecuting") value in child constructor

I have a parent class classA with a variable defined as public string variable. This variable var is initialized in the OnActionExecuting method defined as protected override void OnActionExecuting(ActionExecutingContext test) A child class inherits…
jpo
  • 3,959
  • 20
  • 59
  • 102
1
vote
1 answer

How to redirect from OnActionExecuting in Base Controller without triggering a new request?

This question has already been asked here: How to redirect from OnActionExecuting in Base Controller? but what I don't like in the accepted answer there is that it triggers a new request meaning I run through the logic of the base controller all…
Marko
  • 12,543
  • 10
  • 48
  • 58
0
votes
0 answers

passing parameter from custom filter to web api controller

I am working on a web application in which we are using web-api and oAuth2. I had stored my UserId in front-end but now for security reason I am storing my UserId in backend against the token generated from oAuth2. So I have around 800 api's in my…
Ibrahim shaikh
  • 235
  • 2
  • 15
0
votes
0 answers

Validate request at OnActionExecuting filter

I have a webAPI project written in ASP.NET MVC I want to validate each request to my API project for HTML and Javascript injection. I am writing a filter and on OnActionExecuting() I am trying to read filterContext.ActionArguments My aim is to check…
0
votes
0 answers

EF Core Context always null in BaseController

I've a BaseController but when I call the functions from the child Controllers the Context is always null: public class BaseController : Controller { private readonly TheContext _tContext; public BaseController(TheContext tContext) { …
Vereonix
  • 1,341
  • 5
  • 27
  • 54
0
votes
1 answer

How to redirect from OnActionExecution to an Action in a controller (Asp.net core 5)

Hi guys I’m working on an Asp.net core project targeted .Net 5 I created a class inherited from IActionFilter and I used the OnActionExecution method I did some logic in it and wanna redirect from it to another Action in a Controller. The problem…
JOCKH
  • 339
  • 4
  • 15
0
votes
0 answers

Selenium c# MSTest Specflow execute tests to another device

in my job we have a .NET custom application for testing, we are sending API Requests to another PC where the IIS Express web server is up and running with 81 port. after that test execution starts. Now I've implemented the MSTest+Specflow project…
0
votes
1 answer

How to override "OnActionExecuting" defined in the Startup class inside a controller?

This code run for every incoming request to check whether it contains a valid JWT token. services.AddMvc(options => options.Filters.Add(typeof(JwtAttribute))); That's what I want in most case, except for the first time (when the user is…
Richard77
  • 20,343
  • 46
  • 150
  • 252
0
votes
1 answer

Fire OnActionExecuted even if response is returned from OnActionExecuting

I have following ActionFilter attributes implemented for web apis: LogRequest: This logs the request and response in OnActionExecuted method. ValidateModel: This validates the model and returns BadRequest by setting Response in OnActionExecuting`…