ASP.NET MVC不良做法:具有可选和必需属性的模型

问题描述

Fortify Security检测到代码并出现上述可能的错误

我不明白如何操作模型以避免可能的错误。 可以进行哪些检查以避免错误

我们如何确定是否是实际错误

例如:

public class TestObject
{
        public string ID { get; set; }
        [required]
        public string Name { get; set; }
        [required]
        public string TestService { get; set; }
        public int selected { get; set; }

        public TestObject()
        {
        }
}

 [HttpPost,ValidateAntiForgeryToken()]
        public ActionResult TestObject DataModel,string command)
        {
        }
        

由于TestObject具有[required](必需)属性,而不是必需属性。Fortify可能会引发错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)