I am working on a website (developed in ASP.NET with C #) that has been submitted to me. When I work on a site, I notice that most sites on it have this type of code:
EmailLabel.Visible = false; WhateverButton.Visible = false; AnotherControl.Visible = false; ...
All this is usually done in the site code (in the Page_Load method). In fact, this was put in place to prevent a user who is not a registered user from gaining access to the components (the rule for a site is that a user without registration should not see any part of the site before entering the system). The way described above works ... but it seems quite expensive to always check if the user is registered and then put him in the correct state for all these components.
Is there any other way to approach this problem? Just thinking about this / research, I thought that there might be a way to redirect to the home page if the user does not log in. Even further, I could expand the base page, which will do this for any page that extends the base page. However, my knowledge in this area is limited, so my proposal may not work.
What can SO offer? Anything better? Is it good enough?
Jascav
source share