Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ,

I am a beginner in asp.net.I put on my web a login control,and i want the unlogged in users to dont see a certain page while the logged in users can see this page.So how can i do this ? is this related to membership or roles or what ?

Thanks in advance for any help .
Posted

Read up on ASP.Net Authorization[^]

For the pages you only want a logged in user to see, try this -

* Create a new directory in your web project (call it LoggedIn or whatever)
* Add a new web.config file to the directory you just created
* Add the following to the web.config file

XML
<configuration>
    <system.web>
        <authorization>
            <deny users="?"/>
        </authorization>
    </system.web>
</configuration>


That basically tells ASP.Net that only authenticated (logged in) users can view the content in this directory

* Add a new page to the directory

Test!
* Try and browse to it when not logged in
* Browse to it when logged in

Have a read up on the login controls if you need to create these pages

ASP.Net Login Controls[^]


If you have SQL and haven't already, create an aspnetdb to handle your login + membership

How to create aspnetdb[^]
 
Share this answer
 
Comments
Sandeep Mewara 26-May-11 5:10am    
My 5!
See web.config file for option to declare allowed access for logged-in or non-logged-in users
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900