Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个隐藏的表单字段来删除我的剃刀网页应用程序中的项目
<input type="hidden" value="137" name="id">
用户可以轻松更改项目值并删除其他用户的产品,我们如何确保这一点?
您应该进行服务器端验证,以确保该用户具有编辑/删除(或任何其他操作)该实体的适当授权。
例如,在您的Controller
Controller
[HttpPost] public ActionResult Delete(int? id) { if (CanUserDeleted(id)) { Delete(id); // more magic } else { // Give the user an error } }