If your application throw an sercurity error on
response = (QueryOperationResponse<entityname>)contextd.Query.EndExecute(result);
Add two file as named :
clientacesspolicy.xml and crossdomain.xml at location
C:\Program Files\Microsoft Dynamics CRM\CRMWeb
crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
clientacesspolicy.xml
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="http://<serverurl>/<organization>/xrmservices/2011/organizationdata.svc/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
I have tested this for odataservice.
run your .aspx or .html page with break point