4

I'm trying to hack together an extra feature on top of a POC (smoke and mirrors demo). The POC is on SPS 2007 and I need to integrate with another system.

To facilitate part of this, I need to provide a JSONP endpoint.

I want this URL:

http://sharepoint:2024/Pages/SomeExternalSystem/Payload.aspx?callback=abc

To return this:

abc({ sampleField1: "sampleData1", sampleField2: 234.56 });

It's all smoke and mirrors anyway, so I uploaded this file to SharePoint:

<%@ Page ContentType="text/javascript" Language="C#" %>
<%= Request.QueryString["callback"] %>({
  sampleField1: "sampleData1",
  sampleField2: 234.56
});

(And added a page parser rule to allow it to compile the code blocks.)

No matter what I seem to do, SharePoint emits this instead:

abc({
    sampleField1: "sampleData1",
    sampleField2: 234.56
});
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head>
<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:PublishingContactPicture msdt:dt="string"></mso:PublishingContactPicture>
<mso:PublishingRollupImage msdt:dt="string"></mso:PublishingRollupImage>
<mso:Audience msdt:dt="string"></mso:Audience>
<mso:PublishingContactName msdt:dt="string"></mso:PublishingContactName>
<mso:ContentType msdt:dt="string">Page</mso:ContentType>
<mso:Comments msdt:dt="string"></mso:Comments>
<mso:PublishingContactEmail msdt:dt="string"></mso:PublishingContactEmail>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>

It's proving hard to Google for.

2
  • wouldn't you be better of creating a httpHandler for this?
    – CRice
    Commented Mar 31, 2011 at 5:29
  • Yes - but I was stuck in a POC environment where I didn't have permissions to deploy much. Totally sucky. Commented Apr 4, 2011 at 22:56

1 Answer 1

3

As an extreme hack, this works:

<%@ Page ContentType="text/javascript" Language="C#" %>
<%
    Response.Clear();
    Response.Write(Request.QueryString["callback"]);
    Response.Write("({ sampleField1: \"sampleData1\", sampleField2: 234.56 });");
    Response.Flush();
    Response.End();
%>

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.