Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Updated: According to the MSDN documentation, the ContentLink property can be a Url or file path. You can specify the SourceType property of the webpart so that it knows what to expect for the ContentLink. However, setting the SourceType property will not convert the string in the ContentLink property to a valid url. In fact, the documentation for the PathPattern, the object type that the SourceType takes, states that "you should provide your own validation code for working with the value".

You could include in the property description for the WebPartContentLink how you want the user to enter the information and then check for this in your code.

End Update

using (SPSite site = new SPSite("http://servername/sites/test/"))
       {
            PageViewerWebPart pvwp = new PageViewerWebPart();
            pvwp.Title = "My Page Viewer Web Part";
            pvwp.ContentLink = "http://www.cnn.com";
            this.Controls.Add(pvwp);
        }

The following file(s) have been blocked by the administrator: /SitePages/.

share|improve this question

closed as not a real question by PirateEric, Stuart Pegg, Alex Angas Aug 21 '11 at 12:51

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Would you like to ask a question? –  AlexPoint Aug 19 '11 at 17:06
    
i thought i asked the question.... what happend to my question? somebody hacked it huh –  Abu Hamzah Aug 22 '11 at 10:10
    
Welcome to SharePoint.SE! We need more information to answer your question. Please edit your post and add a question. It will be closed for now, but don't worry - once you have improved the question flag a moderator and it can be reopened. See How do I ask questions here? for general guidelines. –  Kit Menke Aug 23 '11 at 17:47

2 Answers 2

It sounds like you don't have permission to view those Site Pages. I find half the problems I run into with SharePoint are permissions issues. If you have access to an Site Owner or Administrator Account, login to that account and try the code. If not, as always, contact your system administrator.

share|improve this answer

Please try the following piece of code and see if it works.

SPLimitedWebPartManager wpManger = site.OpenWeb().GetLimitedWebPartManager(your page url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

PageViewerWebPart pageViewerWP = new PageViewerWebPart();

pageViewerWP.Title = "My Page Viewer";

pageViewerWP.ContentLink = "http://www.cnn.com";

wpManger.AddWebPart(pageViewerWP, "Top", 0);

The problem that you mentioned was because of the url. Hopefully it will solve your problem.

share|improve this answer
    
here is what i get the error after i use ur code <nativehr>0x80004005</nativehr><nativestack></nativestack>Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb. –  Abu Hamzah Aug 31 '11 at 16:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.