How can I add a ClientAccessPolicy.xml file to the SharePoint 2010 root folder?
-
21-09-2019 - |
Question
In a Visual Studio 2010 SharePoint (2010) project, we can add mapped SharePoint folders, including the {SharePointRoot} folder. When I deploy my project, I can see that the root files end up in the 14-hive, but they never appear in the web site root.
What I really want to accomplish to unit test my Silverlight application which communicates with a SharePoint site. I have tried many variations on the subject, from adding MS unit tests to common class library project, test projects, and finally a Silverlight test project.
When I run my Silverlight test project, all tests that access the SharePoint site fails due to a missing ClientAccessPolicy.xml. I really don't want this file in the SharePoint site, as we don't want to grant access to outside Silverlight apps.
Solution
You can create a Feature to provision files in your web. See how to provision a file.
You can then staple this feature to your site definition or activate it manually (e.g. script in in your deployment scripts).
OTHER TIPS
There may be other ways but the way I do it is with SharePoint Designer. If you open the site you can just drag+drop the ClientAccessPolicy.xml into the root.