MVC 5 中不存在数据注释 [远程]

本文关键字:远程 注释 数据 不存在 MVC | 更新日期: 2023-09-27 18:32:09

我正在尝试在我的应用程序中检查唯一的用户名。我在网上搜索并找到了一个使用[远程]数据注释的不错解决方案。但是,MVC 5 中似乎不再存在它了?这是我在模型中的参考:

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;

如果在 MVC 5 中不再支持 [Remote],您能否建议一种在创建新条目时验证数据库中唯一性的最佳方法?谢谢!

MVC 5 中不存在数据注释 [远程]

[Remote] 属性位于System.Web.Mvc程序集中。 您需要将其包含在 using 语句中才能使用 [Remote] 属性。

下面是引用 [Remote] 属性的 MSDN 页面,供您阅读。