1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Creating Dynamic page using code behind

Creating Dynamic page using code behind

5 posts, 0 answered
  1. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    10 Mar 2011
    Link to this post

    i am try to create dynamic page using below code. and if i try to create i got an error 
    "Telerik.Sitefinity.Pages.Model.PageNode,
    Telerik.Sitefinity.Model was not granted View in Pages
    for principals with IDs 00000000-0000-0000-0000-000000000000" 

    please give some solution.

    Thanks
    Jmr Rafiq.

    Code 
    try
                {
                    var newPageNode = App.WorkWith().Page()
                                         .CreateNewStandardPage(parentGuid,new Guid())  
                                         .Do(p =>
                                         {
                                             p.Name = name;
                                             p.Title = title;
                                             p.UrlName = urlName;
                                             p.ShowInNavigation = false;
                                             p.LastModified = DateTime.UtcNow;
                                             p.DateCreated = DateTime.UtcNow;
                                             p.Page.Title = title;
                                             p.Page.HtmlTitle = title;
                                             p.Description = name;
                                         })
                                         .CheckOut()
                                         .SetTemplateTo(templateGuid)
                                         .Publish()
                                         .SaveChanges();
                SiteMapBase.Cache.Flush();
                }
                catch
                {
                    throw; 
                }
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    10 Mar 2011
    Link to this post
    Hi Jmr,

    The user you use when you create a page does not have permissions for view and respectively create. You need to grant the user with these permissions from the UI or you can use Provider.SuppressSecurityChecks of the PageManager

    Greetings,
    Ivan Dimitrov
    the Telerik team
  3. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    10 Mar 2011
    Link to this post
    thanks!

    if i don't want to check permission should i give below code?
    using (var PageCreation = App.WorkWith())
    {
                        PageCreation.Pages().GetManager().Provider.SuppressSecurityChecks = true;     
    }

    thnks
    Jmr
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    10 Mar 2011
    Link to this post
    Hi Jmr,

    When you suppress the security check you should be able to create your page.

    All the best,
    Ivan Dimitrov
    the Telerik team
  5. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    10 Mar 2011
    Link to this post
    its working! 

    thanks.
    jmr
5 posts, 0 answered