Salvete! I have a Content Editor Web part into which I want to load a simple bit of html (just an input box and a button or two). The file is at /_layouts/myfolder/myfile.html

When I use the "Test Link" option, the file displays fine. But when I "apply" the web part, I get this message in place of the web part: "Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator."

Now, I am using an admin account - a domain admin account, in fact, so it can't be a permission problem.

I also tried it with a simple text file, but still no solution.

I also tried using an absolute address, such as "http://my.portal.org/_layouts/myfolder/myfile.html", but that didn't do anything either.

How is it that the simple html file can be displayed via "test link", but not as the web part?

I don't want to use a page-viewer, becuase I don't want the html to be in an iframe. I know I can put the html directly into the CEWP, but I want to reuse the html in several places and simply maintain one instance of the code.


5 Answers 5


For testing purposes, try putting your html file in a document library in your portal and reference it in the CEWP from there. Eg:

http://my.portal.org/Shared Documents/myfile.html

If this works, then I am guessing it is an authentication issue. Try replicating the issue in Firefox. If it is indeed an authentication issue, you will be prompted for credentials.


After some digging around I found out that you can neither access content from the layouts folder nor from outside the site collection in the ContentLink property. This is a security feature implemented by Microsoft to avoid cross site scripting.

The only way to allow this is to enable Anonymous Access on the site collection. (in case of _layouts folder)

Or if you are referencing content from another site collection, you will have to enable anonymous access on it:

Enable Anonymous Access in SharePoint 2010

(Tested both options on my SP Environment)

The reason why it is working in the PageViewer Webpart is because:

From MSDN:

If the ContentLink URL points outside of the Windows SharePoint Services Web site to a site that requires authentication, then that site must be isolated. For this situation it is recommended that you use the PageViewerWebPart instead of the ContentEditorWebPart. The PageViewerWebPart renders content within an IFrame. With IFrames, security prompting occurs on the client, enabling the target user to specify a user name and password.


Another option is to use the Content Link Webpart (available on Codeplex) which is designed as a workaround for this same issue:

Content Link Web Part for SharePoint

  • Well, that test worked. So you are right, it must be an authentication issue. Now, how do I remedy that to use the file in my _layouts folder? I am already using firefox, and am logged into sharepoint with my domain admin account and I don't get prompted.
    – bgmCoder
    Commented Aug 4, 2012 at 21:56
  • Funny thing is, that the same page's master page comes from that same directory. And there are no issues if I load the page from that directory into a page-viewer web part. That being said, I'm not so sure now, that it is an authentication issue.
    – bgmCoder
    Commented Aug 4, 2012 at 22:11
  • Hi, please check my updated answer. Commented Aug 5, 2012 at 9:10
  • Thank you for the very informative, useful answer. You have solved my quandry. The link for the Content-Link Webpart is awesome, even though I am having trouble getting it to work: contentlinkwebpart.codeplex.com/discussions/390448
    – bgmCoder
    Commented Aug 6, 2012 at 15:31
  • I set my collection to anonymous access same with the library and that did not help. I can't get the Content Link WebPart to run. Any other options?
    – Batman
    Commented Dec 17, 2013 at 19:00

I was playing around with this recently on my dev box trying to setup a CEWP using javascript stored in a central document library. I like the idea of having the code for the widgets in one place which is already versioned and backed up. The fix that finally resolved this for me was setting up the alternate access mappings. Once I setup the AAM for the localhost the issue was cleared.

  • There is something to this! I also discovered the same thing because I called up SCA by http: which would be the way you access it on your LAN. But AAM didn't contain an entry for that, and SCA had issues with it's own non-custom webparts. However, if I access SCA via myserver:8888 everything worked fine. The moral of the story is that webparts don't work properly unless their url paths are correct. AAM is one way of solving that.
    – bgmCoder
    Commented Nov 4, 2014 at 20:55

You cannot link using the content link across sites. I know this first hand. There are, however, workarounds.

I use this in the content editor web part "Content" section and am able to make cross-site references now.

<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<script src="jquery.js" type="text/javascript" langauge="javascript"></script
<script type="text/javascript">
    //enter javascript code here        
  • also note that there will be nothing in the content link field
    – JuanTrev
    Commented Jan 10, 2014 at 15:45

Simply locate your file in Style Library, Mouse Hover and check the hyperlink location...

Something like '/sites/sitename/Style Library/FolderName/Filename.txt'

Just use this in Content Link Property and you are all set!


Recently got this message in SharePoint 2013 Online when referencing a HTML file in the Style Library. However, the issue was simply that the file was checked out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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