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

Try our conversational search powered by Generative AI!

DataFactory CreatingPage problems.

Vote:
 
Hello! I have a need to stop pages from being created. I do so by using the CreatingPage event. To block the creation of a page, I set the CancelAction of the PageEventArgs object to true. My event fires normally, and I block the page creation. However, when I enter edit mode, and attempt to create a page, I am met with an error (after events). The following stack trace describes the problem further: PageReference was not set to a valid value Parameter name: pageLink Actual value was PageReference.EmptyReference. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: PageReference was not set to a valid value Parameter name: pageLink Actual value was PageReference.EmptyReference. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ArgumentOutOfRangeException: PageReference was not set to a valid value Parameter name: pageLink Actual value was PageReference.EmptyReference.] EPiServer.DataAccess.PageLoadDB.Load(PageReference pageLink) +768 EPiServer.DataFactory.ᐂ(PageReference ) +50 EPiServer.DataFactory.GetPage(PageReference pageLink, AccessLevel access) +471 EPiServer.PageBase.GetPage(PageReference pageLink) +173 EPiServer.Edit.EditPanel.get_CurrentPage() +243 EPiServer.UserControlBase.get_CurrentPage() +21 EPiServer.Edit.VersionListControl.PopulateVersionList() +44 EPiServer.Edit.VersionListControl.EditPanel_SavedChanges(Object sender, EventArgs e) +7 EPiServer.Edit.EditPanel.SavePage() +145 EPiServer.EditPage.ᐁ(Object , EventArgs ) +261 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +750 My thoughts are that EPiServer is trying to display the page, even though it was never created, and so complains of an empty reference (since I hook the event at the CreatingPage, the new page has not been assigned a PageLink PageReference yet). If this is the case, is this a known issue? Should I force a redirect in my event handler? (I'd rather not, but if there is no clean solution, I will). If I am wrong, and the problem is something else, I am very very interested in suggestions :) Specs: EPiServer 4.51 Windows server 2003 SP 1 Microsoft SQL Server 2000 SP 4
#17482
Dec 19, 2005 15:45
Vote:
 
Hi! I suggest that you use a validator for this instead, there is a code sample here: http://www.episerver.com/templates/CommunitySample____2630.aspx You can use a validator to stop a page from being created and you can set up specific contidtions that must be met. For example "don't allow the creation of a new page if parent page is of type X and PageName is shorter than 20 characters". If you like you can still cancel the action in the CreatingPage event as this will stop pages being created via code as well - a validator only works in editmode.
#18283
Dec 28, 2005 17:52
* 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.