Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Check page availability?

Vote:
 
Hi, Is it possible to check whether a page is readable by the current user (anonymous or not) _before_ retrieving the page? I'm looking for a way to simply hide information/links from visitors instead of them being automatically redirected to the login page. Regards, /Patrik
#12973
Mar 19, 2007 13:47
Vote:
 
If links to other pages is rendered with any of the EPiServer.WebControls listings, no page is rendered that the user doesn't have priviliges to visit unless you explicity instruct the listing to. So in general it's a good idea to use listings to render links in EPiServer. But sometimes you need to do things with pages that is not in a listing. There is some things to help you find out if the information shall be rendered for the currentuser (or any other user for that matter). // Will fetch the page even if the user doesn't have priviliges to se the page // Will throw an Exception if page with ID=3 doesn't exist. EPiServer.Core.PageData page = EPiServer.Global.EPDataFactory.GetPage(new EPiServer.Core.PageReference(3), EPiServer.Security.AccessControlList.NoAccess); // Check if page is published if (page.CheckPublishedStatus(EPiServer.Core.PagePublishedStatus.Published)) { // Do something } // Check if user has access to read the page if (page.ACL.QueryDistinctAccess(EPiServer.Security.AccessLevel.Read)) { // Do something } I use above functions alot to avoid exceptions in my code. Regards, /HAXEN
#15189
Mar 20, 2007 9:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.