如何能在Identity.GetUserId()提出,要返回一个GUID而不是一个字符串? [英] How can the Identity.GetUserId() be made to return a Guid instead of a string?

查看:180
本文介绍了如何能在Identity.GetUserId()提出,要返回一个GUID而不是一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.Net身份2,但很快希望改变身份3时,它变得更加稳定(有谁知道什么时候可能是?)。这里是我的code的样本:

I am using ASP.Net Identity 2 but soon hope to change to Identity 3 when it becomes more stable (anyone know when that might be?). Here's a sample of my code:

content.ModifiedBy = User.Identity.GetUserId();

内容表存储ModifedBy为UNIQUEIDENTIFIER和内容对象将指定的Guid到ModifiedBy数据类型

The Content table stores ModifedBy as a UNIQUEIDENTIFIER and the Content object assigns a datatype of Guid to ModifiedBy

当我在看的GetUserId(签名)它返回一个字符串。

When I look at the signature for GetUserId() it returns a string.

那么我怎么才能把用户的用户ID和放入ModifiedBy这是一个GUID?

So how can I take the users UserId and put it into the ModifiedBy which is a Guid?

推荐答案

一个GUID可以接受字符串作为构造

A guid can take a string as a constructor

content.ModifiedBy =新的GUID(User.Identity.GetUserId());

content.ModifiedBy = new Guid( User.Identity.GetUserId());

这篇关于如何能在Identity.GetUserId()提出,要返回一个GUID而不是一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆