简体   繁体   中英

Unable to connect to the remote server in CRM 2011 Plugin

I'hv implemented one CRM 2011 plugin which sends sms to Main Phone of Account record on create. But I'm getting an error saying Below is the piece of code used in plugin.

    public static void send(string uid, string password, string message, string no)
    {
        HttpWebRequest myReq =
        (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
        "&msg=" + message + "&phone=" + no + "&provider=way2sms");

        HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse(); //Getting error in this line
        System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
        string responseString = respStreamReader.ReadToEnd();
        respStreamReader.Close();
        myResp.Close();
    }

Whats the solution to resolve this error?

If you are running this Plug-in as Sandboxed, there are some limitations by default on the Outbound URI pattern :

These default Web access restrictions are defined in a registry key on the server running the Microsoft.Crm.Sandbox.HostService.exe process. The value of the registry key can be changed by the System Administrator according to business and security needs. The registry key path on the server is:

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSCRM\\SandboxWorkerOutboundUriPattern

The key value is a regular expression string that defines the Web access restrictions. The default key value is:

"^http[s]?://(?!((localhost[:/])|([.*])|([0-9]+[:/])|(0x[0-9a-f]+[:/])|(((([0-9]+)|(0x[0-9A-F]+)).){3}(([0-9]+)|(0x[0-9A-F]+))[:/]))).+";

By changing this registry key value, you can alter the allowed Web access for sandboxed plug-ins.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM