将整数 ID 添加到 ASP.NET 表单身份验证
在标准表单身份验证中,用户由 Guid 进行标识。我想给我的用户一个 int 类型的 UserId (不一定是主键,只是用于查找的东西)。
向 aspnet_users 表添加附加列是否安全,或者我应该创建一个新表,该表与 UserId 列 FK 并具有生成整数 ID 的唯一列?
后者听起来像是为了一个 int 而造成的性能损失!
编辑 我想创建像 stackoverflow 上那样的 URL。例如。 https://stackoverflow.com/users/23590/greg-b 其中用户 ID 是 int。因此我不想使用Guids。
In the standard forms authentication, users are identified by a Guid. I want to give my users an UserId of type int (doesn't have to be the primary key, just something to do lookup's on).
Is it safe to add an additional column to the aspnet_users table, or should I create a new table which FKs to the UserId column and has a Unique column which generates the integer ID?
The later sounds like a bad performance hit to take just for the sake of an int!
EDIT
I want to create URLs like those on stackoverflow. eg. https://stackoverflow.com/users/23590/greg-b where the User ID is an int. For that reason I don't want to use Guids.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将创建配置文件并将关联的 urlID 存储在那里。 Web 表单没有开箱即用的配置文件,但您可以在此处查看解决方法:
http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx
使用配置文件的优点是,您可以利用所有现有逻辑,除了构建 URL 之外,无需自己编写大量自定义代码。
如果您是使用 ASP.NET 3.5 或更高版本。
更新:有点类似的问题:
使用 CRC 缩短 GUID
I'd create profiles and store the associated urlID there. Web Forms don't have Profiles available out of the box, but you can see a workaround here:
http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx
The advantage of using Profiles is that you can tap into all the existing logic and won't have to write as much custom code yourself, aside from constructing the URL.
You could combine this with Routing for friendly URLs, if you're using ASP.NET 3.5 or up.
UPDATE: kinda similar question:
Shorter GUID using CRC