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?
Hej Andres, I found the problem and it had to do with the database connection/cache in my development environment, but now is working.
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