通过隐藏字段将模型 ID 传递给控制器安全吗?
想象一下,我有一个采用员工类型模型的视图。员工定义如下: 员工{ ID 整数, 员工姓名字符串 } 如果我想更新数据库中的员工,我必须将模型传递给操作。 更新员工(员工 emp) 在隐藏字段中定义员工 ID 会存在安全风险,不是吗? 有人可以轻松地进入检查员并传递他们喜欢的任何 ID,并且该员工的信息将会更新。
Imagine I have a view that takes a model of type employee. Employee is defined like so:
Employee{
ID int,
Employee Name string
}
If I wanted to update an employee in the database I have to pass the model to the action.
UpdateEmployee(Employee emp)
Defining the employee ID in a hidden field would be a security risk wouldn't it?
Someone could easily go into the inspector and pass whatever ID they like and the information will be updated for that employee.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论