[英]How to verify datatype in C# asp.net MVC
I pass the custom data type of C# struct and now I want to get know which type it is in the attribute I put on them in ActionFilterAttribute
. 我传递了C#结构的自定义数据类型,现在我想知道它是在
ActionFilterAttribute
放入它们的属性中的类型。
How can I check the type of viewdata.Model in ActionFilterAttribute? 如何在ActionFilterAttribute中检查viewdata.Model的类型?
filterContext.ParentActionViewContext.ViewData.Model.GetType();
这将为您提供模型的类型
您是否尝试过在结构上调用GetType ()?
if (filterContext.ParentActionViewContext.ViewData.Model is YourType) {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.