限制某些页面——在每个页面上重定向?或者在母版页上通过查看 url 中的当前页面?

发布于 2024-10-16 03:43:03 字数 149 浏览 3 评论 0原文

根据不同的用户模式,除非拥有有效的会话密钥,否则用户不应访问某些页面。

在您看来,在母版页中列出可接受的页面并检查当前页面对于当前用户是否有效会更好吗?或者在每个子页面上处理这个问题?

我正在考虑母版页,只是想听听您的输入是什么。

谢谢

Per different user mode, some pages should not be accessible by users unless they have a valid session key.

In your opinions -- would it be better to have a list of acceptable pages in the master page, and check if the current page is valid for the current user? Or handle this on every child page?

I'm thinking master page, just want to hear what your input would be.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

变身佩奇 2024-10-23 03:43:03

母版页或定义的基页是放置此类逻辑的最佳位置。这样做的原因是您将过滤逻辑放在一处。为每个页面复制千篇一律的代码会导致以后出现问题。

您还应该使这个逻辑尽可能通用,并将将要更改的数据(您的页面列表、您的权限等)存储在数据库中。当您想要添加页面时,这将最大限度地减少代码更改。

最后,您需要为未定义的页面定义某种默认行为。理想情况下,您应该锁定没有权限数据的页面。这将确保您不会意外允许访问需要限制的页面。

The master page, or a defined base page, is the best place to put this kind of logic. The reason for this is that you are putting your filtering logic in one place. Copying cookie cutter code for each page will lead to problems down the road.

You should also make this logic as generic as possible, and store data that's going to change (your list of pages, your permissions, etc...) in the database. This will minimize code changes down the road when you want to add pages.

Finally, you need to define some sort of default behavior for pages that are not defined. Ideally, you would lock down pages that don't have permission data. This will ensure that you don't accidentally allow access to a page that needs to be restricted.

少女情怀诗 2024-10-23 03:43:03

我至少看到两种情况:

  1. 如果您要重定向的所有页面都有一个母版页,则使用母版页。

  2. 如果有一个母版页但页面不相同,并且并非该母版页的所有页面都被重定向,但只有其中一些页面最好在当前页面上检查这一点,而不是在母版页。

原因是,如果你把它放在集合页面上,那么你需要去扔一个案例列表,并检查你所在的女巫页面的母版页。这需要更多的时间和更多的内存,并且如果您创建页面然后更改它等,则包含更多出错的风险。在母版页上也很难知道哪个页面是子页面并识别它。

在当前页面上,您只需要检查您的用户是否可以看到它。

There are at least two cases that I see:

  1. If there is one master page for all pages that you go to redirect, then use master page.

  2. If there is one master page but the pages are not the same and not all pages of this master page are redirect but only some of them its is better to check this on current page and not on master page.

The reason is that if you place it on muster page, then you need to go throw a case list, and check on the master page in witch page you are. This takes more time and more memory and contain more risk to make errors if you create a page, then you change it etc. Also is difficult on the master page to know what page is the children and identified it.

On the current page you only need to check if your user can see it or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文