More in this section

Forums / Developing with Sitefinity / Primary Key for sf_PageBase Table

Primary Key for sf_PageBase Table

2 posts, 0 answered
  1. Richa
    Richa avatar
    69 posts
    04 Jun 2009
    18 Sep 2009
    Link to this post
    Am trying to create a table RolePageMapping and add a foreign key to this new table to the sf_PageBase table's column: ID, which does show as Primary key in the database; but when i try to add the foreign key, i get the following error:
    Isnt this the table where all pages in a site are primarily stored?
    Actually what am trying to achieve is:
    There's a user: UserA with role: RoleA;
    There's a user: UserB with role: RoleB;
    There's are blogs: BlogA and BlogB;
    There are sitefinity pages: PageA and PageB which have BlogPosts control on them. The control shows all posts in BlogA on PageA and all posts in BlogB on PageB. These pages have permission where only users with role RoleA can view PageA and similarly for all other roles and pages.
    Now when UserA logs in, I want him to land on PageA. For this I have a sitefinity page: ClientLogin.aspx which has a usercontrol on it which has a .net login control (ID: ClientLogin) in it. In the code behind I get the current role for the user using UserManager.GetCurrentUserRoles() and then from the table RolePageMapping I want to get the page for his role and set ClientLogin.DestinationPageUrl = that page.
    Do you have an alternative to this situation, where I can redirect the user to a particular page without having to create the new table: RolePageMapping?
  2. Nikolai
    Nikolai avatar
    216 posts
    01 Jun 2017
    24 Sep 2009
    Link to this post
    Hi Richa,

    The issue is in your table. The sf_PageBase uses both Application and Id columns to create unique identifier not just the Id. So you will have to create the same type of unique identifier for your custom table like I did in the attached screen shot. You must map both Application and Id columns for the foreign key to create a 1:1 relation.

    We do not recommend you creating such tables and constraints because Sitefinity uses Nolics ORM and such actions may brake the ORM's ability to read/write data. Also your project upgrades the database to newer versions of Sitefinity when you update the assemblies, and this may result in some serious errors with the relations.

    Based on my understanding on what your trying to achieve, I suggest you this approach:
    1. Create your pages and blogs - A and B
    2. On page A place BlogPost control that is filtered to show only Blog A
    3. Create Role A
    4. On the page's properties tab set Anonymous access to Deny
    5. On the page's permissions click Break inheritance. This will make the page to have it's own set of permissions.
    6. Give View permissions to Role A

    Repeat the same procedure for Page B, Blog B and Role B
    The reason for this is that by denying Anonymous access you will force the user to go through Login process before he can view the page.

    Hope this helps.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered