在查询字符串中使用创建的 UserId 的 ASP.NET 成员资格
您好,我目前正在学习 .net,并正在使用 .net 构建我的第一个真正的网站。
我只是想知道人们是否认为可以在查询字符串中使用生成的成员资格 UserId?并使用它作为数据库中的外键将相关信息链接到该用户?
Hi I am currently learning .net and am building my first real website using .net.
I was just wondering if people considered it ok to use the generated membership UserId in the query string? and also to use this as a foreign key in a database to link relevant information to this user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么在查询字符串中需要它?它是由...提供的,
即使这不会导致安全问题,我也不会向用户显示如此敏感的数据,但这只是因为如果每个人都能看到比他需要看到的更多内容,那么应用程序看起来就不安全。您可以将其临时存储在会话中,以便将其从第 1 页传递到第 2 页。
如果要将 UserID 保存为外键,可以使用 MembershipProvider 提供的 uniqueid。
如果您想使用整数(可读性、更少的磁盘空间),则必须创建一个表(
aspnet_UserID
),以一对一的关系将 guid 映射到您的 int-ID。还为aspnet_Users
表上的插入和删除创建触发器,例如:
Why do you need it in a querystring? It is provided by...
I wouldn't display such sensitive data users even if this wouldn't cause security issues, but simply because an application looks unsafe if everybody can see more than he needs to see. You could store it temporarily in the Session to pass it from page 1 to page2.
If you want to save the UserID as foreignkey its possible to use the uniqueid provided by the MembershipProvider.
If you want to use an integer instead(readability, less disk space), you have to create a table(
aspnet_UserID
) that maps the guid to your int-ID in a one-to-one relationship. Create also a trigger for inserts and deletes on theaspnet_Users
-table, for example:and
使用 FK 将用户相关数据链接到用户肯定是好的,具体取决于数据库的设计。
一般来说,除非确实需要,否则我不会将用户 ID 放入查询字符串中,如果您已启用并且正确支持用户身份验证,则当前连接的用户的信息可在 User.Identity 和 Primary 类中找到。
surely is good to link user related data to the user with FK, depending on the design of your database.
in general I would not put user id in the querystring unless really required, if you have enabled and you support user authentication properly, the information of the currently connected user is available in the User.Identity and Principal classes.
通过模糊原则实现的良好安全性规定 id 不应包含在查询字符串中。
http://en.wikipedia.org/wiki/Security_through_obscurity
但是如果 你有一个适当保护的应用程序,id 应该没问题。
无论如何,您可能应该将 UserId 存储在会话中,这样它就不会传输到浏览器。
Good security through obscurity principles dictate id's should not be included in the query string.
http://en.wikipedia.org/wiki/Security_through_obscurity
But then IF you have a properly secured application, id's should be fine.
You should probably be storing the UserId in the session anyway, so it is not transmitted to the browser.