Last post Jan 07, 2012 06:38 PM by anogio
Jan 07, 2012 07:02 AM|anogio|LINK
I have a created an asp.net website featuring a photogallery and the abilitiy to upload photos and comments on photos. All works very nicely and I have happy with the results, but as a final part of my project, I need to do...something...to ensure that a
user who is not logged in, will not be able to upload said photos or post comments, just view them.
I used the visual studio 2010 asp.net template which has the Master Page with login area (not mvc or razor version).
I noticed when browsing through the code that there were anonymous templates and loggedin templates.
Can I use these templates to disable, or change the functionality of controls on the fly to redirect the user to a log on page when an anonymous user clicks then? and if so, how would I go about doing it?
I realise the question is a bit vague, but it is hard to be more specific without posting entire pages of code.
Jan 07, 2012 01:51 PM|b471code3|LINK
What I would do is wrap the upload control in an <asp:Panel> and set the visibility. If you're only concerned about someone who is logged in being able to upload a file then you can get away with the IsAuthenticated property below. I'd check this on page
Panel1.Visible = true;
Panel1.Visible = false;
If you are concerned about people in certian roles having access you can do the above AND could check to see if a user is in a role:
// let them upload
// dont let them upload
Jan 07, 2012 06:38 PM|anogio|LINK
Outstanding, thank you.