asp.net-mvc – 将List参数传递到ASP.NET MVC3中的自定义操作过
发布时间:2020-12-15 21:01:57 所属栏目:asp.Net 来源:网络整理
导读:我怎么能把List解析成自定义动作过滤器(比如输入参数)? public class CustomFilter : ActionFilterAttribute{ public ListMyEnumType InputParameter { get; set; } public override void OnActionExecuting(ActionExecutingContext filterContext) { base.
我怎么能把List解析成自定义动作过滤器(比如输入参数)?
public class CustomFilter : ActionFilterAttribute { public List<MyEnumType> InputParameter { get; set; } public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); } } [CustomFilter(InputParameter = new List<MyEnumType>() { MyEnumType.Type } )] public SomeActionInController() { } 我得错了错误 'InputParameter' is not a valid named attribute argument because it is not a valid attribute parameter type 解决方法
操作过滤器参数是操作过滤器的属性:
[CustomFilter(InputParameter=10)] public SomeActionInController() { } public class CustomFilter : ActionFilterAttribute { public int InputParameter { get; set; } public override void OnActionExecuting(ActionExecutingContext filterContext) { // access this.InputParameter base.OnActionExecuting(filterContext); } } 属性参数类型仅限于此处描述的类型 – http://msdn.microsoft.com/en-us/library/aa664615%28v=vs.71%29.aspx 您可以通过属性构造函数传递集合,如此处所述 – Can I initialize a C# attribute with an array or other variable number of arguments? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 将* .domain.com和domain.com重定向到www.domai
- SimpleMembership与ASP.NET MVC 4中的自定义数据库模式
- 经过一段时间的工作,IIS / ASP.Net无法从WCF Web服务的web.
- asp.net – MVC3:如何强制Html.TextBoxFor使用模型值而不是
- asp.net – 如何仅发布捆绑/缩小的脚本
- asp-classic – 使用TFS 2010“构建”经典ASP
- ASP.NET MVC 4 JSON绑定到视图模型 – 嵌套对象错误
- asp.net – 对齐和填充为asp:CheckBoxList
- 添加依赖于.net核心csproj文件
- asp.net-mvc – Asp.net MVC中的TimeSpan和“24:00”解析错
推荐文章
站长推荐
- asp.net – HttpContext.Current.Cache可用于所有
- asp.net – 将下一个/上一年的按钮添加到asp日历
- asp.net – IIS Express似乎不会挑选对applicati
- 具有Entity Framework Code Only和ASP.NET MVC的
- asp.net-mvc – 在调用action之前发生的ASP.NET
- asp.net-mvc – 将变量与静态html连接起来的语法
- asp.net-mvc – 当前上下文错误中不存在名称“Ur
- asp.net-web-api – 无法为Web API OData端点解析
- 在Azure网络应用程序中显示ASP.NET 5错误页面
- asp.net-mvc – 在MVC Controller中访问GET参数
热点阅读