【发布时间】:2015-03-30 09:20:57
【问题描述】:
我有一个简单的 .net Web 应用程序。我的目标是从登录页面开始。注册成功后,用户应该可以访问网站的真实内容。有些链接应该能够在注册后但不能在注册之前访问。我正在为此工作几天,在互联网上找不到任何东西。
【问题讨论】:
我有一个简单的 .net Web 应用程序。我的目标是从登录页面开始。注册成功后,用户应该可以访问网站的真实内容。有些链接应该能够在注册后但不能在注册之前访问。我正在为此工作几天,在互联网上找不到任何东西。
【问题讨论】:
使用Use the ASP.NET Membership Provider。
不要使用Session 自行滚动。它将是vulnerable to attacks such as session fixation。
话虽如此,但确实有一些缺陷,例如it does not clear the server side of sessions after logout。
这将使您能够使用authorization rules in web.config:
<location path="AdminFolder">
<system.web>
<authorization>
<allow roles="Admin"/> //Allows users in Admin role
<deny users="*"/> // deny everyone else
</authorization>
</system.web>
</location>
【讨论】:
注册成功后将页面重定向到真实内容,如果用户未登录,则将会话设置为内容页面重定向回登录或注册页面
/*set session in content page this will prevent the direct access to
content page */
if(Session['success]==null){
redirect to login or signup page ;
}
【讨论】: