c# - 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 可能会引发错误。
解决方案
推荐阅读
- jquery - 在外部单击时关闭由 .slideToggle 操作的 jQuery 菜单
- vb.net - 清除函数后无法将数据插入数据表
- google-cloud-platform - gcloud:匹配集群和计算区域
- java - @PathVariable 不适用于非拉丁语言
- spring-boot - Couchbase 的 Spring Data - 计算数据库中的元素
- java - Pom.xml 和 org.springframework.boot 的属性 2.1.8.RELEASE Redshift Cluster V1.0.10393
- angular - 如何将 onchange 生命周期替换为 changeDetection?
- reactjs - react-final-form如何上传、替换、删除多张图片
- ios - NSFaceIDUsageDescription 用于 Face ID 使用说明。touch ID 使用说明如何?
- c - 哪个是为树的每个节点生成唯一键的最佳散列函数?