tags:

views:

63

answers:

2

I have myown login page.If any user access any page directly(without login),i want to redirect unauthorized user to login page....How it possible.....Using Generic Handler is there any chance? or how can i do it ?

A: 

Have a look at your web.config.... there is a section WHICH USERS ARE ALLOWED TO VIEW WHAT RESOURCE and where to redirect those not allowed.

TomTom
k....thank you sir....Nice to hear your advice....Once again thanks.....
Joby Kurian
+3  A: 

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>
citronas
Understand, though, that use must now employ the FormsAuthentication class (as explained here: http://msdn.microsoft.com/en-us/library/aa480476.aspx ) Basically the redirect after a successful login must be authorized else it will just keep bouncing your user back to the login aspx.
tobrien