开发者

How to verify datatype in C# asp.net MVC

开发者 https://www.devze.com 2023-02-25 08:21 出处:网络
开发者_如何学编程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 theminActionFilterAttribute.

开发者_如何学编程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.

How can I check the type of viewdata.Model in ActionFilterAttribute?


filterContext.ParentActionViewContext.ViewData.Model.GetType();

This will give you type of the model


Have you tried calling GetType() on the struct?


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

精彩评论

暂无评论...
验证码 换一张
取 消