Windows Authenticated WCF JsonP Sample ? Work?
-
Wednesday, October 26, 2011 11:22 PM
Is it possible to have a wcf service c# .net 4 expose jsonp on IIS and Windows Authentication? I have tried numerous ways but I am unable to achieve this.
Is this possible?
Do you have sample code?thx
dave
All Replies
-
Thursday, October 27, 2011 8:07 AM
JSONP cannot be used together with windows authentication, or any other authentication type. If you try to do that your service will throw the following error:
Cross domain javascript callback is not supported in authenticated services
Please mark posts as answers/helpful if it answers your question.
Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper.
Visit my blog: http://blogs.microsoft.co.il/blogs/idof -
Thursday, October 27, 2011 12:50 PM
Yes that appears to the be the problem.
How can Javascript access data from another server if I cannot use jsonp? In our environment we have mutliple servers/domains and I would like to host a service (protected by windows authentication) from one domain and serve it up to other sites which are in other domains and access via javascript?
I would like to access from javascript and I would like to utilize wcf. Is this even possible?
thx
dave- Edited by daveNETGuy Thursday, October 27, 2011 12:51 PM
-
Friday, October 28, 2011 2:14 AMModerator
JSONP with authentication can make your service vulnerable to XSS attacks. So it's not allowed. The WC3 has a draft on cross original JavaScript access: http://www.w3.org/TR/access-control/. Most modern browsers already support it, but still be careful as this is not a standard, just a draft. But note IE is different from other browsers. IE requires you to use XDomainRequest, while other browsers allows you to use normal XMLHttpRequest.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
Windows Azure Technical Forum Support Team Blog- Proposed As Answer by Jermski Friday, November 11, 2011 11:35 PM
-
Friday, November 11, 2011 6:59 PM
Hi Dave - Did you figure out a workaround for this?
I also have the same requirement.
-
Friday, November 11, 2011 11:35 PM
I have a workaround for this -
http://jeremybranham.wordpress.com/2011/11/11/authenticated-wcf-service-that-returns-jsonp/
- Proposed As Answer by Jermski Friday, November 11, 2011 11:35 PM
-
Saturday, November 12, 2011 1:20 AM
Have you tried this solution?
Can you share code if you have it working? (windows authentication?)
Right now, I am not using wcf (as a work around) and simply outputting jsonp formatted output to the browser. My client javascript/jquery is able to read this fine. I would very much rather use wcf however.
Please let me know if you have it working?
thx -dave
dave -
Saturday, November 12, 2011 4:29 AM
yes. I wrote that blog up today. i will update it with some examples soon.

