相关疑难解决方法(0)

控制器和动作的MVC属性

有没有办法在Controller级别添加属性,但不能在特定操作上添加.例如,如果我在我的控制器中有10个动作,那些动作中只有一个不需要我创建的特定属性.

[MyAttribute]
public class MyController : Controller
{
    public ActionResult Action1() {}
    public ActionResult Action2() {}

    [Remove_MyAttribute]
    public ActionResult Action3() {}
}

我可能会将此Action移动到另一个控制器(但不喜欢)或者我可以将MyAttribute应用于除Action3之外的所有操作,但只是想如果有更简单的方法?

c# asp.net-mvc

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1