views:

23

answers:

1

I try to execute this code in Silcerlight 4 contol hosted in webpart:

clientCtx = new ClientContext(ApplicationContext.Current.Url);
clientCtx.ValidateOnClient = true;
clientCtx.Load(clientCtx.Web);
clientCtx.ExecuteQueryAsync(updateConnectionStatus, Failed);

but it fails and go Failed method and I recive error: "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

When I turn off security validation in central administration everything works. How to avoid this issue?

A: 

You might have a cross-domain posting issue. See the following SO question that deails how to provision the clientaccesspolicy.xml file to prevent cross-domain posting issues.

http://stackoverflow.com/questions/2302825/how-can-i-add-a-clientaccesspolicy-xml-file-to-the-sharepoint-2010-root-folder

Peter Walke