I have my own login page. If any us开发者_开发知识库er access any page directly (without login), I want to redirect unauthorized user to a login page. How is it possible? Using Generic Handler, is there a chance? Or how can I do it?
You can set this behaviour in the web.config
Example: (this enables authentication)
<authentication mode="Forms">
<forms cookieless="AutoDetect" protection="All" slidingExpiration="true" loginUrl="~/login.aspx"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
(the specified path is excluded from authentication. meaning you can access the file/directory without authentication. useful for image, scripts, styles directories)
<location path="login.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
精彩评论