English 中文(简体)
我知道,将采取什么行动来实施“执行裁决”。
原标题:How do I know which action will execute using an ActionExecutingContext object?

我将这一行动过滤器安装在所有行动方法实施之前。

protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
  //code omitted 
  UpdateModel(MyModel);
}

在行动A、B、C本应执行,而不是D时,我希望这一行动能够更新这一模式。 我如何防止这种过滤行动在D执行时更新模型? 因此,可以知道如何使用上面的<>行动......ExecutingContentfilContext?

增 编

最佳回答

你这样做的方法是,将行动A、B和C与属性联系起来,而不是D。

你们得到了答案,但是,你打算这样做,这确实是坏事。 如果有人在另一个控制器上写了一种行动方法,如果这一特性should,那么,那么,通过机会选择了你过滤的名字。 独角兽部队赢得了 t,这是一场明显的丑恶,但是,正如人们所告诉的那样。 这将是一条 maintain夜。

无,这样做的清洁办法是,将属性从控制层移至所有控制器的操作方法级,而如果存在某种行动方法,则这种归属应如此。 这使得人们很容易看到,仅仅看看看控制器法,当其特性会发生时,如果它不发生,它就会像预期的那样发挥作用。

问题回答
filterContext.ActionDescriptor.ActionName




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签