【发布时间】:2023-03-13 14:55:02
【问题描述】:
private static void Getproperties(Object Model) {
Type objType = Model.GetType();
PropertyInfo[] properties = objType.GetProperties();
foreach (PropertyInfo property in properties)
{
object propValue;
//Checking if property is indexed
if(property.GetIndexParameters().Length ==0)
propValue = property.GetValue(Model,null);
else
{
// want to retrieve collection stored in property index not passing 0 index returning element at 0 location ,how can i get whole list
propValue = property.GetValue(objectModel,new Object[]{0});
}
var elems = propValue as IList;
.... }
如何获取列表类型的属性值,我在模型中的属性是列表类型,例如我的模型包含一个列表属性
List<User>
想要创建一个过滤器并添加到我可以检查潜在 Xss 攻击的操作,模型是否包含任何此类攻击
【问题讨论】:
标签: c# reflection asp.net-mvc-5 action-filter