开发者

Cannot retrieve the URL specified in the Content Link property

开发者 https://www.devze.com 2023-03-29 21:35 出处:网络
using (SPSite site = new SPSite(\"http://servername/sites/test/\")) { 开发者_JS百科PageViewerWebPart pvwp = new PageViewerWebPart();
using (SPSite site = new SPSite("http://servername/sites/test/"))
       {
      开发者_JS百科      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.

sometimes i get the error The Web Part has timed out and sometimes the above error. and i make sure that my internet is working so i opend the browser and able to access the site


I could not reproduce this, so i would assume it's an permission issue. Try running your code with elevated privileges:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号