Custom Page Provider Page ID

Vote:
 

Does the Page ID for a page displayed via a Page Provider have to be unique.

 e.g. if I have a blank site, and I create the initial start page the ID assigned to this page is 3. Can I then have a page beneath this start page provided by a custom page provider with the page ID of 3 ?

If not, then no matter what page ID I assign to my page provider pages (e.g. I could start them at 10,000) eventually I will get page ID conflicts.

How have other addressed this when using page providers ?

Many thanks,

Chris

#32942
Sep 25, 2009 13:14
Vote:
 

A Page ID only have to be unique within a page provider, so you can have two page providers delivering Page ID 3. The identifier of a page is passed using the PageReference class which holds information on where the ID belongs (and converts to and from a string as well).

You could ofcourse offset your ID with a few millions anyway to protect you against bugs in the templates during development (if someone tries to access a page using the raw integer value you get a page not found exception instead of the wrong page which may pass unnoticed).

 

 

#32953
Sep 25, 2009 15:52
Vote:
 

As Per says, page IDs only have to be unique within a provider - it's the PageReference which is unique across the site.

Never work directly with page IDs in your code - if you always work with PageReference objects then you won't get any conflicts. The ConstructPageReference() helper method in the page provider base class allows you to format PageReference values properly for your provider.

 

#33247
Oct 05, 2009 19:30
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.