Try our conversational search powered by Generative AI!

GetDefaultPageData cannot call new PageTypes

Vote:
 

 Hi:

 

I followed the tutorial How to create a page programatically and it work fine on new CMS 6 installation. However the aim was to add that functionallity to an existing CMS 5. I tried to replicate the same steps in a development environment but I get problems with my recently added Page Type.

PageData myPage = EPiServer.DataFactory.Instance.GetDefaultPageData(new PageReference(1), 34);

 I get the following error:

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

34 is the ID for my new Page Type.

If I use instead the ID for another Page Type (created before), I get no error in that line of code. I have tried several Page Types and they work with no problem, is just the new one I created. The parent page has rights to have the new Page Type created.

I have been looking and trying to fix the problem but I can get this to work with the new page type, I have deleted and created a new one, including the aspx files but get the same error.

Thanks

#48968
Feb 24, 2011 17:37
Vote:
 

Could it be that the root page aint page id 1?, if you try other pages there, where your page type is allowed bellow does it work then?

 

#48988
Feb 25, 2011 12:40
Vote:
 

Hej Andres, I found the problem and it had to do with the database connection/cache in my development environment, but now is working.

#49039
Edited, Mar 01, 2011 18:03
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.