无法检索Content Link属性中指定的URL

时间:2011-08-19 16:03:06

标签: sharepoint-2010 web-parts

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";
        }

Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator.

有时我会收到错误The Web Part has timed out,有时会收到上述错误。我确保我的互联网正常工作,所以我打开浏览器并能够访问该网站

1 个答案:

答案 0 :(得分:1)

我无法重现这一点,所以我认为这是一个许可问题。尝试使用提升的权限运行代码:

SPSecurity.RunWithElevatedPrivileges(delegate
{
    using (var site = new SPSite("http://servername/sites/test/"))
    {
        var pvwp = new PageViewerWebPart
        {
            Title = "My Page Viewer Web Part",
            ContentLink = "http://www.cnn.com"
        };
    }
});