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 11th, 2011, 04:48 AM
Registered User
 
Join Date: Apr 2011
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default Try it out code (p644)

Hi there,
I couldn't understand the use of this code in the try it out -step 7:


Code:
 if (User.Identity.Name != photoAlbumOwner && !User.IsInRole("Managers"))
            {
                Response.Redirect("~/");
            }
from what i understand, if you are not logged in generally you cannot get to this page anyways!... secondly does response.redirect bounce the unauthorised user to the home page?? thanks

Last edited by jmahdi; May 11th, 2011 at 04:50 AM.. Reason: clarification
 
Old May 11th, 2011, 04:53 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,

Quote:
if you are not logged in generally you cannot get to this page anyways!...
That's correct. But this code does more: it also redirects the user away when he's not the owner of the album, and not a manager. This way, you can't edit someone else's album.

Quote:
secondly does response.redirect bounce the unauthorised user to the home page??
The Response.Redirect you posted sends users that are not the owner of the album and not a manager to the homepage.
The default behavior of ASP.NET for unauthenticated users hitting this page is to send them to the configured login page which is ~/Login.aspx by default.

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 11th, 2011, 05:09 AM
Registered User
 
Join Date: Apr 2011
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default

thanks a bunch





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to save html page source code? Jaymond Flurrie Access VBA 2 July 2nd, 2019 06:04 PM
Double clicking control does not add code to Code Behind Paul Walton BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 September 25th, 2009 05:40 PM
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM





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