为了防止用户绕过登录页面进入其他网页,除了在每张页面都用session进行判断外,还有没有其他更简单的方法,比如在Session_Start中进行一次判断就可以了。
解决方案 »
- 动态添加控件,如何在后台获取ClientID?
- asp页面 和asp.net后台代码怎么互动
- 求ajax.net调用后台事件函数的写法
- realplay在线播放rm的问题,困扰几天了,一直播不出来
- 如何在.Net的移动开发中获得手机号码或手机IMEI
- php代码转成.net
- 数据访问问题
- 怎样传这个参数?
- 关于DataGrid中记录选择并传递的问题!(急)
- 发放VB.NET下《How To Create a Pop-Up Calendar User Web Control》,请高手把它改写成C#,然后贴上来。
- 请问如何使用asp.net获得服务器段操作系统的语言版本?(在线等)
- 如何取得自定义web控件中的两个下拉框的值?
一直用session
在WEB.CONFIG文件中配置
<authentication mode="Forms"/>
<forms name="cookie" loginUrl=""……>
……
</authentication>
<authorization>
<deny users="*"/>
</authorization>
添加认证Handle,具体的忘记是Web.Config中的哪个Section了,可以查查帮助
<configuration>
<configSections>
<sectionGroup name="system.net">
<section name="authenticationModules"
type="System.Net.Configuration.NetAuthenticationModuleHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
<section name="webRequestModules"
type="System.Net.Configuration.WebRequestModuleHandler,
System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
</sectionGroup> <sectionGroup name="system.web">
<section name="authorization"
type="System.Web.Configuration.AuthorizationConfigHandler,
System.Web, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
<section name="sessionState"
type="System.Web.SessionState.SessionStateSectionHandler,
System.Web, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
allowDefinition="MachineToApplication"/>
</sectionGroup>
</configSections> <system.net>
<! — Net Class Settings would go here. -->
</system.net>
<system.web>
<authorization>
<allow users="*"/> <!-- Allow all users -->
<!-- Allow or deny specific users.
allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<sessionState
sqlConnectionString="data source=localhost;
Integrated Security=SSPI;
Initial Catalog=northwind"
cookieless="false"
timeout="10"/>
</system.web>
</configuration>