Click here to Skip to main content
15,390,185 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi I am New to,I want to restrict the users to view only the contact us page and allow ADMIN to view all the pages of the website.

What I have tried:

    <form id="form1" runat="server">
        <div class="menu">

                <li class="navigation_first_item"><a href="Default.aspx">Home</a></li>
                <li class="navigation_s"><a href="Add User.aspx">Add User</a></li>
                <li><a href="Registrationpage.aspx">Register Employee</a></li>
                <li><a href="Contact.aspx">Contact</a></li>

            <div class="logoutLblPos">

                <label class="logoutLblPos">
                <br />
                    <span class="auto-style1">Time</span> <span class="auto-style2">:</span>
            <asp:Label ID="lbltime" Text="" runat="server" Style="color: black"></asp:Label>

                <span class="auto-style3"><span class="auto-style4">User </span> :</span><asp:Label ID="lblusername" Text="" runat="server" Style="color: black"></asp:Label>
                <br />
                <asp:Button ID="btnlogout" Text="logout" runat="server" OnClick="btnlogout_Click" Style="height: 26px"></asp:Button>

            <div class="left"></div>
            <div class="right"></div>

            <div class="clear"></div>
            <div class="content"></div>

            <div class="Content">

                <asp:ContentPlaceHolder ID="ContentBody" runat="server">
Updated 31-Jan-17 21:18pm

1 solution

Sometimes you want to allow public access to your registeration page and want to restrict access to rest of the site only to logged / authenticated users .i.e. do not allow anonymous access. Say your registration page is called register.aspx in your site's root folder. In the web.config of your website's root folder you need to have following setup.


<authentication mode="Forms"/>

<authorization> <deny users="?"/> //this will restrict anonymous user access

<location path="register.aspx"> //path here is path to your register.aspx page e.g. it could be ~/publicpages/register.aspx
<allow users="*"/> // this will allow access to everyone to register.aspx

Till now we saw either allow users or to authenticated users only. But there could be cases where we want to allow particular user to certain pages but deny everyone else (authenticated as well as anonymous).

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