0

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/.

3
  • 1
    Would you like to ask a question?
    – AlexPoint
    Aug 19, 2011 at 17:06
  • i thought i asked the question.... what happend to my question? somebody hacked it huh
    – Nick Kahn
    Aug 22, 2011 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, 2011 at 17:47

2 Answers 2

1

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.

1

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.

1
  • 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.
    – Nick Kahn
    Aug 31, 2011 at 16:53

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