Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 16th, 2007, 01:45 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to redirect an non-registered admin to login

Hello All,
            I am developing a Shopping Cart application in which according to our client's requirement i am having 2 different login pages for admin and for users. Now the problem is that i am having a separate folder "Admin" and what i want to do is whenever in the browser if someone types the url of any of the .aspx pages of the admin folder he should get redirected to the admin login page and once logged in he can have access to admin folder. For this in main project's web.config i am writing it as -
<location path="Admin">
<system.web>
<authorization>
<allow users="?"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

Please suggest me how to proceed and correct the code. Your help is highly appreciated. Thanks in advance.

  #2 (permalink)  
Old November 16th, 2007, 02:10 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This literally says
<allow users="?"/>
<deny users="*"/>

Allow all anon users and deny everyone.


In any event, I would create a second web.config in my admin directory with this code:
<configuration>
   <system.web>
     <authentication mode="Forms"/>
     <forms name="login" loginUrl="login.aspx" />
     <authorization>
         <deny users="?"/>
     </authorization>
   </system.web>
 </configuration>

Also take a look at these URLs
http://www.codeproject.com/aspnet/Fo...nAuthorizn.asp
http://msdn2.microsoft.com/en-us/library/wce3kxhd.aspx

hth

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
  #3 (permalink)  
Old November 21st, 2007, 11:23 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

are you using roles and management of asp.net 2.0?

thanks......
  #4 (permalink)  
Old November 22nd, 2007, 07:17 AM
Friend of Wrox
 
Join Date: May 2006
Location: Northampton, United Kingdom.
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default

Set up a role then in page.load check the role the user belongs to

If User.Identity.IsAuthenticated = False Then
    Server.Transfer("Default.aspx")
Else
  If (Roles.IsUserInRole(User.Identity.Name, "Admin")) Then
     Response.Redirect("DefaultLoginforAdmin.aspx")
  Else
     Response.Redirect("DefaultLoginforNormalUser.aspx" )
  End If
End If

Not necessarily the best solution but it might help.

  #5 (permalink)  
Old November 26th, 2007, 08:47 AM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you all but dparsons your idea worked............thanks a lot and thanks to all.....



Similar Threads
Thread Thread Starter Forum Replies Last Post
CMS - admin login does not work peppie BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 October 20th, 2007 08:46 AM
Admin login help banned Classic ASP Databases 2 May 8th, 2006 07:50 PM
admin login mujnu PHP How-To 0 February 5th, 2006 08:03 AM
Unable to login - Email address not registered ??! xrow Forum and Wrox.com Feedback 2 November 19th, 2004 06:28 AM
can't login into PHPNuke as admin anshul Pro PHP 0 August 5th, 2004 04:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.