Thursday, September 27, 2007

Content Query WebPart(CopyUtil.aspx) and Anonymous Access on your site

Content Query WebPart (CQWP) is a great little webpart, which lets you display any content from any level of your site on a webpart page. The problem with this webpart is that it was not designed for anonymous access, at least not completely. O.



If you have a site enabled with anonymous access and if you drop this web part on a page. you will notice that this webpart shows the contents to anonymous user correctly however when you click on any of the list item(hyperlink), It will challenge you to enter windows credentials or you will get "403" forbidden error.

After examines I found that Content Query Webpart usages copyutil.aspx page in layouts folder which in turn redirects to appropriate edit form depending on the type of the list. That's where the problem lies.

The "CopyUtil" class inherits from a generic class called "UnsecuredLayoutsPageBase". This class has a property called AllowAnonymousAccess . Which the inheriting class should override and set it to the true or false based on how web application is configured







Workaround:

1) Override the ContentQuery Web Part's XSLT and instead of using copyutils.aspx use the "dispform.aspx"

2) Create a cusotm copyutil.aspx page and override the AllowAnonymous property

4 comments:

Unknown said...

Hi, i have the same problem as you had with the CQWP. I was wondering if you could share the code.. or procedure for your workaround as described in your blog.

Thanks!

/Daniel

Unknown said...

I was also running into the problems with CopyUtil.aspx and anonymous users. I created a quick blog entry that describes how to create your own Item Style for linking to blog entries (notice, the example is 'hard coded' for links to blog posts):

Content Query Web Part (CQWP) with Anonymous Access


I hope this helps and thanks again for your blog.

Anonymous said...

I would also like to see the code, if that is possible. I looked at the CopuUtil.apsx file and all I see is a bunch of references. So, how do I modify the CopuUtil.aspx file to overrirde the AllowAnonymous access method.

Kris

Mike said...

Daniel & Kris,

Here is how you modify CopyUtil to allow anonymous access to CQWP links:
Anonymous access and the Content by Query Web Part (CQWP): Fixing CopyUtil.aspx