PublishPageDraft(editPage.Id, true) gives error

Posted by Community Admin on 04-Aug-2018 21:57

PublishPageDraft(editPage.Id, true) gives error

All Replies

Posted by Community Admin on 19-Jul-2011 00:00

I need to check if I can use sitefinity's login details to connect to my company's existing webapp. MembershipUserCollection helps me get the user details which I can put in the page's session which directs to my company's site. I read one of your previous threads which said that you can create a user control and convert to sitefinity widget and drag it to your page into sitefinity and work on session state through that user control.
1. Can you elaborate on this?

2. I have the page with myUserControl. How can I access this page in visual studio?  (I got ans to this from your prev ans)

3. I am querying my page and trying to modify the user control of a page. 

pManager.PublishPageDraft(editPage.Id, true); gives me UnauthorizedAccessException. Why is this happening? 

Posted by Community Admin on 20-Jul-2011 00:00

No Answer?

Posted by Community Admin on 25-Jul-2011 00:00

Hello,

Please take a look at this tutorial from our documentation, which deals with creating and importing user controls as widgets in Sitefinity, which can later be dropped onto pages/templates.
Concerning the second issue with PublishPageDraft() method, can you please make sure that you are logged in with a user that has sufficient rights to perform this operation, when running your code and let us know if the problems persist.

Greetings,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 25-Jul-2011 00:00

I am the one who created the project which makes me the admin. And since I am testing some stuff there are no other users for now. Are there any specific permissions which I need to change for this?

Posted by Community Admin on 26-Jul-2011 00:00

Hello U,

Can you please try disabling output cache for your pages, and also clear the browser cache. Then log on with the administrator credentials and run the code again. That's a really strange issue, besides permissions I don't believe there could be anything else that would invoke such an error. On the other hand the admin account has no restrictions at all so there should be also no problems with it.
 Is there anything specific about the project, or any information that might help us reproduce the problem locally?  If so, please share with us the exact steps you are taking to reproduce this, and also the code you are using, although it looks fine from the excerpt that you have pasted. I would kindly ask you to check whether this behavior will reproduce on a new project, as well.

Greetings,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Jul-2011 00:00

There were different things that I was testing as I am totally new to these things. Following are the steps
 I have a new project created. Have a new page MyPage_Test. Created a user control in visual studio and added that as a widget in MyPage_Test. Created another page in visual studio WebForm1.aspx. Wanted to test the DeleteControl sample given in the documentation which is as follows:
private void DeleteControl()
       
            PageManager pManager = PageManager.GetManager();
            PageData page = pManager.GetPageDataList().Where(t => t.Title == "MyPage_TEST").SingleOrDefault();
            PageDraft editPage = pManager.EditPage(page.Id, false);


            //remove the first child control in the controls collection
            if (editPage.Controls.Count > 0)
                editPage.Controls.RemoveAt(0);


            pManager.PublishPageDraft(editPage.Id, true);
            pManager.SaveChanges();
       

So editPage.Controls.RemoveAt(0); gives me my user control but gives error at  pManager.PublishPageDraft(editPage.Id, true);

I also  need to know how can I use the Sitefinity authentication credentials  to authorize a user to have access to another application so that it can be used to access other permissions not stored within sitefinity.

Posted by Community Admin on 28-Jul-2011 00:00

??

Posted by Community Admin on 29-Jul-2011 00:00

Hello U,

That's a really strange issue, besides permissions I don't believe there could be anything else that would invoke such an error.   The method that you are calling is indeed going through a security check for the current user's login status and permissions, so that's where this exception might be thrown, however we're not able to reproduce the issue locally. Just in case, did you try disabling output cache fro your pages, and also reset any caching settings you might have applied in IIS, and try if the error will reproduce?
 I would kindly ask you to check whether this behavior will reproduce on a new project, as well. If it doesn't then is it possible to provide us with a download link or FTP where I can obtain a copy of your project's files and a backup of the database, so I can set it up locally and inspect the problems further.


Regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Aug-2011 00:00

Can you also help me with this

I also  need to know how can I use the Sitefinity authentication credentials  to authorize a user to have access to another application so that it can be used to access other permissions not stored within sitefinity.

Posted by Community Admin on 01-Aug-2011 00:00

Hello,

Please take a look at this post that explains authentication process and provides a sample code

http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/windows-authentication.aspx#1655610

In case for Single Sign On you need to create a repository to store the cookies. Then you need to use the decryption and encryption keys to authenticate the user without forcing it to use the credentials. Sitefinity 4.x does not use the standard ASP.Net forms authentication due to some limitations.In order to authenticate a user from custom login form in Sitefinity 4.0 you have to use one of the overloads of SecurityManager.AuthenticateUser(…) methods. This method will set the appropriate cookies for the current response.You can set the timeout of the authentication cookie in Sitefinity’s backend user interface or configuration files. To set it form the UI please login and navigate to ~/Sitefinity/Administration/Settings/Advanced, in the left panel click on Security node. In the right panel find the following fields and set the appropriate values: AuthCookieTimeout and RolesCookieTimeout. Sitefinity can use different authentication methods simultaneously (forms / windows / basic and etc.). The default encryption algorithm used by Sitefinity is different (stronger and FIBS compliant) than the default ASP.Net algorithm. That’s why you cannot directly interchange cookies or other encrypted information even though you set the same validation and decryption keys. You also have to set identical encryption algorithms. Still the best way to authenticate with Sitefinity is to use its API.
You can also use another ASP.NET provider in Sitefinity which you can declare as explained in this post


Kind regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Aug-2011 00:00

Thanks a lot Ivan!

This thread is closed