【问题标题】:It is possible to access a parameter from an action filter in mvc3?可以从 mvc3 中的操作过滤器访问参数吗?
【发布时间】:2013-07-05 15:19:23
【问题描述】:

我在我的 mvc 3 Web 应用程序中有一个自定义操作过滤器,它在数据库上执行日志,我想获取有关正在访问用户的操作的更多信息,所以我现在有这个代码:

[ActionFilters.ProductStream(Message = "PUBLISH a Product")]
public ActionResult PublishProducts(PublishedContainerVO publishedContainer) {

//some code

}

我想做这样的事情:

[ActionFilters.ProductStream(Message = "PUBLISH a Product", Id = publishedContainer.Id)]
public ActionResult PublishProducts(PublishedContainerVO publishedContainer) {

//some code

}

这可能吗?我已经看到在 Action 过滤器中我可以通过他的键访问该参数,但在这种情况下......我有一个复杂的对象而不是一个简单的 id。

【问题讨论】:

    标签: asp.net-mvc-3 parameters action-filter custom-action-filter


    【解决方案1】:

    你不能,因为元数据是在编译时创建的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-16
      • 2020-05-12
      • 2013-09-16
      • 2011-10-04
      • 2017-12-27
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多