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 May 7th, 2012, 02:31 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default web forms authorization

I am having trouble with the following xml code in the web.config file when I am doing some additional exercises contained in your book:

Code:
<authorization>
<deny users = "*" />
<allow users = "Supervisors">
</authorization>
<location path = "/accounting/payables">
For whatever strange reason this code is not acting like its intended design. I can't quite figure it out. I can't seem to weed out anybody but the supervisors to the accounting path file locations. Am I doing something wrong here? It has got me confused.
 
Old May 7th, 2012, 02:43 PM
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,

Take a look at page 611, in the How It Works section to see why this doesn't work as expected....

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 May 7th, 2012, 03:51 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default I looked at page 611

I just looked at page 611. Everything looks fine to me just as how you have it in the book. I know I did everything right on this as explained in your book of that I am certain. I just don't see any discrepancies whatsoever.
 
Old May 7th, 2012, 05:07 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take another look at this quote from the book:

Quote:
It starts scanning the various rules (allow and deny elements with roles or users attributes to specify the users or roles that are affected by the rule) and as soon as it finds a rule, it stops the scanning process and applies that rule.
Then take a look at this:

Code:
 
<authorization>
  <deny users = "*" />
  <allow users = "Supervisors">
</authorization>
The first rule blocks access to *all* users, including those in the Supervisors role. That rule with match, and thus access is blocked for everyone. Swap these two rules and it should work.

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 May 7th, 2012, 05:16 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default okay

You know what? I just noticed this before I got your email for the response I am giving you here. You are right, the two lines of xml code were accidentally transposed when I typed them into the web.config file. The allow users line of XML code in the web.config file has to come first before the deny statement. Is that correct? I think I got it working just fine now. It was just such a simple, little accidental mistype that you wouldn't normally think to look that small. It was just a dumb typing mistake on my part. Oh geeze. I feel so stupid because I made such a small little mistake like that. This kind of simple mistake can be quite common I would wager. Has anything like that ever happened to you sometimes maybe in the past?
 
Old May 7th, 2012, 05:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
The allow users line of XML code in the web.config file has to come first before the deny statement. Is that correct?
Not necessarily. It depends on the rules you want to apply. You could block unauthenticated users first, for example. It's a matter of setting up the right flow.

Quote:
Has anything like that ever happened to you sometimes maybe in the past?
Millions of times..... :-)

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
Using Web Forms and MVC Together in a Web Server thorin119 BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 0 January 20th, 2010 06:16 AM
Forms authorization and dynamic redirect LarryB ASP.NET 1.0 and 1.1 Basics 3 September 21st, 2007 02:41 PM
Web Forms Keith Smith BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 8 February 24th, 2007 02:49 PM
Web Forms issues bluetonic VB.NET 2002/2003 Basics 0 August 6th, 2006 09:12 AM





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