Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 August 21st, 2010, 12:05 AM
Authorized User
 
Join Date: Apr 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default Question about page redirection - chapter 15

What makes the site go directly to Login.aspx whenever you try to cut and paste the URL of management folder without logging in as a manager (manager role)? Is it because ASP automatically detects the LOGIN CONTROL and assumes that the page which has it should be called?

Chapter 15, page 549 step 12.

thanks
 
Old August 21st, 2010, 03:48 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 there,

Nope, it's not the Login control as you could have many different pages in your site with a Login control.

It's centralized in web.config. The <forms /> element has a loginUrl attribute that defaults to Login,aspx. You can override it if you want:

Code:
 
<authentication mode="Forms">
  <forms loginUrl="SomeOtherPage.aspx"></forms>
</authentication>
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!
 
Old August 22nd, 2010, 05:00 PM
Authorized User
 
Join Date: Apr 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thanks, but I'm referring to your C# version, I cannot find that section that you mentioned. Whenever I try to add a new album without logging in, or try to access 'my profile', it redirects me to the Login page. Is it something to do with ASP.NET <authorization> section?

thanks again.
 
Old August 22nd, 2010, 06:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can't find it, because I just made up the loginUrl. Since it has a default value of Login.aspx, there's no need to specify it explicitly.

The loginUrl just defines the default login URL. It doesn't handle the security. This is done by the <location /> elements.
Did you check out the security chapter? This stuff is discussed in great detail in that chapter.

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!
 
Old August 29th, 2010, 11:18 PM
Authorized User
 
Join Date: Apr 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Yes, I checked the security chapter and there was never any mention of a default file named LOGIN.ASPX that ASP.NET checks/redirects to when the attribute LoginURL is not used.

Is it always necessary to name the file Login.aspx whenever creating a login page when I decided not to use the attribute LoginURL as you have mentioned?
 
Old August 30th, 2010, 03:43 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

No, correct. LoginUrl is not mentioned in that chapter. I corrected that in the 4.0 version of the book with:

Quote:
The authentication mechanism of ASP.NET by default assumes you have a page called Login.aspx in the root of your site that is used to let users log in. To be functional, the minimum that this page requires is a Login control. If you want to use a different page, you can specify its path in the <forms /> element under <authentication /> like this:
Code:
<authentication mode=”Forms”> <forms loginUrl=”MyLoginPage.aspx” /> </authentication>
With this configuration you tell the ASP.NET runtime to load the page MyLoginPage.aspx whenever a user needs to present her credentials. Note that on the Login page (configured in the loginUrl) the VisibleWhenLoggedIn property of the Login control has no effect. On the configured Login page, the Login control is always visible. If you want to hide it you can use a LoginView control, as you see in a later exercise.
And yes, you either need to rely on Login.aspx or override the attribute. There is a default which you can use, but obviously when you don't like the default you need to override it somehow.

I was referring to the security chapter as a response to your question of why it redirects to the login page. Access to files and folders is determined by the <location /> elements in the config file.

Hope this helps,

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!
 
Old August 30th, 2010, 07:59 PM
Authorized User
 
Join Date: Apr 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thank you , this is very helpful. It has enlighten me so much. Will grab a copy of your new book from Amazon in due time so I can be updated on the changes as well.

cheers Imar





Similar Threads
Thread Thread Starter Forum Replies Last Post
CHAPTER 15,PAGE 533 dyla BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 April 14th, 2010 01:20 PM
CHAPTER 15,PAGE 533 dyla BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 0 April 13th, 2010 10:58 AM
Chapter 15 Role Management Question will.wei BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 April 9th, 2009 02:17 AM
Chapter 15 FooReader.Net Question maxint40 BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 5 April 13th, 2007 09:14 AM
Chapter 15 - functions.php question buzzuh BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 7th, 2004 08:31 AM





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