如何在C#asp.net MVC中验证数据类型

如何在C#asp.net MVC中验证数据类型,c#,asp.net-mvc,types,C#,Asp.net Mvc,Types,我传递了自定义数据类型C#struct,现在我想知道它在actionfilteratAttribute中的属性中是什么类型 如何在ActionFilterAttribute中检查viewdata.Model的类型 filterContext.ParentActionViewContext.ViewData.Model.GetType(); 这将为您提供模型的类型您是否尝试在结构上调用()了 if (filterContext.ParentActionViewContext.ViewData.M

我传递了自定义数据类型C#struct,现在我想知道它在
actionfilteratAttribute
中的属性中是什么类型

如何在ActionFilterAttribute中检查viewdata.Model的类型

filterContext.ParentActionViewContext.ViewData.Model.GetType();
这将为您提供模型的类型

您是否尝试在结构上调用()了

if (filterContext.ParentActionViewContext.ViewData.Model is YourType) {
}