Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
 
Old February 12th, 2011, 10:48 AM
Authorized User
 
Join Date: Feb 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default Ch17 - redirect to Login

Imar,

This is a great book for learning ASP.Net. Thanks for your tremendous effort. Your "how it works" sections are particularly good.

In Chapter 17, we create permissions that deny access to MyProfile if a user is not logged in. If we try to access the page when not logged in, we are re-directed to the login page. How does this redirection happen? So far as I can see, we don't specify what the system should do.
 
Old February 12th, 2011, 10:56 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi DennisE,

Thank you; good to hear you like the book.

The behavior you're describing is built in the ASP.NET Framework. When you try to access a page you don't have permissions to (determined by the <location /> element in this case, ASP.NET automatically redirects you to the Login.aspx page. You can override the actual Login page (in case your login page is placed in a different folder or has a different name) by setting the loginUrl attribute on the forms element like this:

Code:
<authentication mode="Forms">
  <forms loginUrl="~/SomeFolder/SomePage.aspx" timeout="2880" />
</authentication>
Obviously, in this example, SomePage.aspx does need to exist and contain a Login control.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
DennisE (February 12th, 2011)
 
Old February 12th, 2011, 11:17 AM
Authorized User
 
Join Date: Feb 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default

That answers my question precisely. Thanks for your insightful reply.
 
Old February 12th, 2011, 11:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.

You may want to take another look at Chapter 16, page 587/588 where this is discussed as well.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Shop - Why do redirect to Login page? nhvubak BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 August 3rd, 2010 05:04 AM
Redirect from login westannex ASP.NET 3.5 Basics 2 June 15th, 2009 02:19 PM
How to redirect an non-registered admin to login nrlahoti ASP.NET 2.0 Professional 4 November 26th, 2007 08:47 AM
ch17 php4 hymns BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 August 21st, 2006 04:25 AM
Help login redirect and file viewing danjapro Classic ASP Components 0 December 6th, 2004 06:33 PM





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