Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created a proxy aspx page following this guide: http://www.sharepointjohn.com/sharepoint-2010-cross-domain-proxy-page-for-client-side-scripts/

I deployed the solution to the farm using the two Powershell commands provided in the tutorial. When I use the proxy via javascript ajax on a page it only works when I'm logged into sharepoint. When I'm not logged in and hit the page I get a 302 (Moved Temporarily) and it tries to redirect the ajax request to the sharepoint loggin page for my site. It's as if the proxy page in the solution hasn't been published yet. Why is this? How do I publish the page?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The source code the project can be found over here on CodePlex: http://sharepointproxypage.codeplex.com/.

This article (http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/f8b567d4-1cd0-46c1-ac47-4498af88d798) suggests that in order to use custom application pages (which is what the Proxy page is) with anonymous users you need to override the AllowAnonymousAccess setting.

protected override bool AllowAnonymousAccess 
{    
      get { return true; }    
}

Download the source code and then add the code above to the Proxy.aspx.cs file before the OnInit call like such:

public partial class Proxy : LayoutsPageBase
{
    protected override bool AllowAnonymousAccess 
    {    
          get { return true; }    
    }
    protected override void OnInit(EventArgs e)
    {
        ProcessProxyRequest();
    }
share|improve this answer
    
BTW, the reason this isn't in the main project is that it could be a security concern and should only be made available to anonymous users when necessary. –  John Chapman Apr 26 '12 at 17:34
    
Good point, I'll just deny any request that's not to the only url I need this for. –  WSkinner Apr 26 '12 at 19:01
    
Another thing you could do is add some functionality to the proxy page that retrieves the URL from a list by the ID. That way it can only return content you have added to that list. (And when referencing the proxy page, you would give the ID rather than the page URL) –  John Chapman Apr 26 '12 at 20:51
    
that worked, thanks! –  WSkinner Apr 26 '12 at 20:57
    
Awesome. I should probably add some additional functionality (like this) to the base project in a configurable way. When I get the time. /sigh –  John Chapman Apr 26 '12 at 21:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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