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
0
votes
1 answer

Issue in action call after IActionFilter OnActionExecuting function

I am using IActionFilter OnActionExecuting function for some security check, but when it calls it check a condition and if that conditions fails i want to redirect it to login action but the problem is, it call the next action as well which i donot…
Fraz Sundal
  • 10,288
  • 22
  • 81
  • 132
0
votes
1 answer

ASP.NET MVC 2 A problem with OnActionExecuting method

I have a controller called "SomeController". I want to check if the user is logged in or if has persissions to execute any action in that controller. To do so, I read that article…
Tony
  • 12,405
  • 36
  • 126
  • 226
0
votes
1 answer

Override of OnActionExecuting and a .ashx file upload

I have a MVC project that uses a 3rd party upload .ashx page. I also have the following override for OnActionExecuting(ActionExecutingContext filterContext): public override void OnActionExecuting(ActionExecutingContext filterContext) { …
Buchannon
  • 1,671
  • 16
  • 28
0
votes
1 answer

Determining whether a request is from the server or a client c#

Is there a way to determine whether an OnActionExecuting(ActionExecutingContext filterContext) request is coming from the server or client?
keenns
  • 863
  • 4
  • 14
  • 26
0
votes
2 answers

MVC ActionFilterAttribute - Get a value from the action

In MVC I have a service registered in Startup I use to validate actions like so: Startup.cs public void ConfigureServices(IServiceCollection services) { //services.AddCaching(); services.AddSession(); services.AddMvc(); …
0
votes
1 answer

Web API - Access Custom Attribute Properties inside ActionFilterAttribute OnActionExecuting

I need to access a property inside a custom DataAnnotation attribute. How can I access this attribute in order to set the response value? The attribute is added to the model property. public class BirthDateAttribute : ValidationAttribute { …
0
votes
1 answer

Understanding ActionExecutingContext.Result within an ActionFilterAtrribute

I recently read this code that makes an MVC Web API allow CORS (Cross origing resource sharing). I understand that the ActionFilterAtrribute makes this a filter, but I'm not sure what's going on in this class: AllowCORS. public class AllowCORS :…
0
votes
1 answer

Asp .Net MVC on action executing - Get the value of action parameter values of user defined types on action executing

I want to log the each action method parameter name and its corresponding values in the database as key value pair. As part of this, I am using OnActionExecuting ActionFilterAttribute, since it will be the right place (OnActionExecuting…
Prem
  • 1
  • 1
  • 2
0
votes
1 answer

Alternative to StackTrace.GetFrame... to finding the action on a controller that called a method

Setup: I have written an ASP.NET MVC wizard, based originally on Steve Sanderson's wizard (Pro ASP.NET MVC 2 Framework). My wizard is generic and is a dream. Each Wizard step is an action. However, I have now released an app that uses the wizard…
awrigley
  • 13,481
  • 10
  • 83
  • 129
0
votes
1 answer

How to add QueryString in OnActionExecuting()?

i want to add two queryString in current request URL if it is not exsist Edited: I tried this --- public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.RequestContext.HttpContext.Request.QueryString["mid"]…
Amogh
  • 4,453
  • 11
  • 45
  • 106
0
votes
1 answer

Session being cleared in ASP.NET MVC

What happens to Session between the Session_Start call and OnActionExecuting in an ActionFilterAttribute. For some reason, when I set something like this: protected void Session_Start(object sender, EventArgs e) { Session["GoToBuyPage"] =…
Matt Vaughan
  • 1,135
  • 2
  • 13
  • 19
-3
votes
1 answer

How to find a specific value in an IDictionary?

This IDictionary contains user data I'm logging into mongodb. The issue is the TValue is a complex object. The TKey is simply the class name. For example: public class UserData { public string FirstName { get; set; } public…
koshi
  • 311
  • 3
  • 8
1 2
3