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

I have a application on which i want to stop the users to navigate to admin pages which they can access by giving direct url. can any body please to help me.


i already tried the code

XML
<authentication mode="Forms">
      <forms loginUrl="~/default.aspx" defaultUrl="~/default.aspx"></forms>
    </authentication>


XML
<location path="Admin_Pages">
    <system.web>
      <authorization>
        <allow users="admin_Pages"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>


in web config file.
But now the actual users also can not logon. after clicking login button they are redirecting the default page.
Posted
Updated 4-Jul-12 19:21pm
v2

You login url should be your login page not default page

XML
<authentication mode="Forms">
      <forms loginUrl="~/login.aspx" defaultUrl="~/login.aspx"></forms>
    </authentication>



here is link to article talks about the same : Form authentication and authorization in ASP.NET[^]
 
Share this answer
 
v2
Comments
Sebastian T Xavier 5-Jul-12 1:49am    
my +5
Rahul Rajat Singh 5-Jul-12 2:08am    
good answer. +5.
use session at the time of login.
and after logout or Close the window clear the session.
and at page_load event check session. if session is null then redirect to the login pagae.
 
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