开发者_如何学编程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) {
}
精彩评论