【发布时间】:2014-07-04 12:41:20
【问题描述】:
我创建了以下类:
public class Config
{
public Guid UserId { get; set; }
public string AdminJSON { get; set; }
public string UserJSON { get; set; }
}
当我查询我正在使用的数据时:
Config config = await db.Configs.FindAsync(User.Identity.GetUserId());
这是进行查找的正确方法吗?似乎 User.Identity.GetUserId() 返回一个 细绳。我是否应该将其转换为返回 GUID。
我还有另一个问题:
UserId = User.Identity.GetUserId()
这也失败了。我尝试通过在 User.Identity.GetUserId() 之前添加 (Guid) 来进行强制转换,但是这会显示一条消息,提示错误 1 无法将类型“字符串”转换为“System.Guid”
它出错了,因为它不能
【问题讨论】:
标签: c# asp.net asp.net-identity