2

We are trying to use an ajax call to get list data for an anonymous site. We are using this on our intranet site and it works well. We build an html file that calls the list service (via ajax) and we populate a placeholder tag on the page. All the html files are stored in the siteassets folder and are easy to maintain.

Now I have a public facing site that I would like to do the same. However, my ajax call is returning a 400 Bad Request in Firefox as anonymously. The same page works like a dream if logged in.

I have searched and found lots of pages saying that this cannot be done, however, I have not seen a solution or alternate way to do this without using a sandboxed solution.

If there a way to do this other than sandboxed?

1 Answer 1

2

Listdata.svc service usage requires an authenticated connection. For your public site, I do recommend implement your custom service (be it a simple asmx service, rest service, wcf service) or create a custom generic handler (eg: listdata.ashx) that will return, in a similar fashion to what you would receive from listdata.svc the expected content.

You can safely craft any CAML queries returning whatever you need in your service layer and sending back as JSON / XML ready to be consumed without the limitation of the mandatary authenticated connection from the listdata.svc service layer.

4
  • I'm kind of a newbie at all this. Can I create a handler as you suggest that would be in a sandboxed porject? I don't want to have to deploy a farm solution.
    – user14919
    Commented Feb 18, 2013 at 20:28
  • No, unfortunately, for a handler, you'll need to register it in you web.config which make it impossible in a sandbox solution. But do you really need anymous + sandbox ? Commented Feb 18, 2013 at 21:02
  • We want to get away from farm solutions as I can see as the site grows we are going to have to continually add to the handler new calls to different lists. Unless I don't understand this right. It's a public facing site that I want to store and the data in lists and just put the data via jquery. Sorry if I don't understand. :-)
    – user14919
    Commented Feb 18, 2013 at 21:24
  • You could authenticate all anonymous users to a generic account (without their notice) so that you could listdata.svc. This will require anyway a farm solution to put the relevant pieces in place but will give you freedom of not creating a new generic ashx. You can afterward build sandbox only solutions on the top of it. Commented Feb 19, 2013 at 11:12

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.