【发布时间】:2017-06-22 05:35:35
【问题描述】:
我有一个与 AspNetUser 一对(一或零)关系的 UserProfile 模型。
用户资料:
public class UserProfile
{
public int Id { get; set; }
public virtual ApplicationUser ApplicationUser { get; set; }
[Required]
[Display(Name = "Full Name")]
public string FullName { get; set; }
}
如何验证正在修改的 UserProfile 是用户自己的数据? 我在我的 POST 和 GET 方法上放置了一个 [Authorize] 属性以进行编辑,但我仍然需要验证用户是否正在编辑他们自己的数据。
这可以使用另一个属性来完成,这样我就不必在我的方法中重复代码,如果可以,我该如何编码?
【问题讨论】:
标签: c# asp.net asp.net-mvc