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