问题描述
大家好,
在我的网站中,任何人都可以通过在浏览器地址中写入url来访问特定页面,
如何防止只有经过身份验证的用户才能访问这些页面?
谢谢
Hi every body,
In my website, any one can access specific pages by write url in Browser Address,
How to prevent that where these pages are not allowed for any one but for Authenticated users only?
Thanks
推荐答案
Session["LoggedIn"]
variable,位于
variable , in
OnLoad
事件处理程序中,以查看用户是否已登录;如果他尚未登录,则将他重定向到登录页面.
在登录页面中,如果用户成功登录,则将
event handler ,to see if the user is logged in or not; if he had not logged in then redirect him to login page.
In login page if the user logged in successfully set the
Session["LoggedIn"]
设置为true.
将此用户控件放置在要对其进行限制的每个页面中,或者可以将其放置在母版页中以对所有页面应用限制,而无需将其放置在每个单独的页面中.
to true.
Place this user control in every page you want to have restriction in it, or you can place it in master page to apply restriction to all pages without the need to place it in each individual page.
这篇关于如何防止未经授权的用户访问特定的网站页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!