Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #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.....

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.