Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将多个域映射到同一个网站并将域与数据库进行比较以决定要显示的内容。好吧,其中一个域需要对所有页面进行表单身份验证,而其他站点则不需要。当使用某个域时,有条件地在整个站点上应用用户角色的最佳方式是什么?
我通过检查我使用的域以及是否是需要身份验证的域来解决这个问题,如果用户不在设置的用户角色中,我将它们重定向到登录页面。我只是将它添加到每个页面的“Page_Load”方法中。
if (site == 13) { if (!User.IsInRole("SomeUserRole")) { Response.Redirect("~/Account/Login.aspx"); } }