有什么方法可以将非静态值传递给actionfilter参数,如下所示?
public class ProcuctController : Controller
{
private int userID = 1;
[TestFilter(x=userID)]
public ActionResult Index()
{
}
}
最佳答案
不,没有。属性被烘焙到生成的程序集的元数据中,并且所有值都应该在编译时已知。您只能将常量值作为属性属性传递。这是 .NET 的限制,而不是 MVC。
关于asp.net-mvc - 将非静态值传递给 Action 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4625709/