综合技术

Is it generally acceptable to use a primary key as an identifier of an HTML element?

微信扫一扫,分享到朋友圈

Is it generally acceptable to use a primary key as an identifier of an HTML element?
0

I have an HTML list whose <ul>
items have ids same as the primary keys in the database table. Is it generally acceptable to expose the primary keys for this purpose? If not, what efficient methods can be used to mask them?

There’s generally no problem with this, if your site is otherwise secure. Anyone who can access a primary key shouldn’t be able to do anything with that knowledge. If you’re relying on them being a secret, that’s security through obscurity, which isn’t much security at all.

However, if your primary keys are numeric, they are not valid element IDs. Element IDs must begin with a letter ( src
). You can do, e.g.

<span id="foo-<%= Model.PrimaryKey %>"></span>

阅读原文...


Hello, buddy!

Context: The Future of Data Is in Streaming

上一篇

Powerbeats Pro are the Bluetooth earbuds to beat

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
Is it generally acceptable to use a primary key as an identifier of an HTML element&quest;

长按储存图像,分享给朋友