[英]How to verify datatype in C# asp.net MVC
我傳遞了C#結構的自定義數據類型,現在我想知道它是在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.