Click here to Skip to main content
16,017,922 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
am create a e-commerce website.
there are two type of user roll
1:-Admin Page
2:-User Login Pages
now I have a problem
when I login with user account and give admin pages link
user can access easily admin pages
how can I fixed this problem when user write admin page link then page going on its home page

What I have tried:

role based authentication for user or amdin
Posted
Updated 8-Mar-16 1:49am
v2
Comments
debashishPaul 7-Mar-16 16:55pm    
Are you using MVC or WebForm?
Arslan saif 8-Mar-16 4:32am    
Webform
Philippe Mori 9-Mar-16 12:16pm    
Tons of tutorial exists on the web...

Try create a sites in folder of "Admins", allows only roles admin access in web.config.

XML
<location path="Admins">
        <system.web>
            <authorization>
                <allow roles="Admin" />
                <deny users="*" />
            </authorization>
        </system.web>
    </location>
 
Share this answer
 
v2
Comments
Arslan saif 8-Mar-16 4:33am    
can you explain this more
It jump back to home page because the authorization is not allowed.

Have you ever using
C#
Microsoft.AspNet.Providers

okay , you know how to use ASP.NET Web Sites Administration Tool, right?

set a "Admins" roles right there, and assign that user to Admins roles.

?

then followed the same as i show you on top post.

then in login view, create a value "Admins" in "Edit Item" and switch it in rolegroup,
last add hyperlink to bring you to that pages.

ASP.NET
<asp:LoginView ID="LoginView1" runat="server">
<RoleGroups>
	<asp:RoleGroup Roles="Admins">
  		<ContentTemplate>
   			<asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "~/Admins/ManageAdmin.aspx?id=123" %>' runat="server" Target="_blank" />
  		</ContentTemplate>
	</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
 
Share this answer
 
v7

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