web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Request for the permission of type 'System.Net.WebPermission...' ?

(0) ShareShare
ReportReport
Posted on by

Hi,
I am trying to send a request from plugin using the HttpWebRequest but it gives me the exception below about the permission of the type 'System.Net.WebPermission...'.
The code is

//RequestHandler is a class which sends the HttpWebRequest and login() takes 3 parameters and return the message if it was accepted or not
RequestHandler logObj = new RequestHandler();
string webResponse = logObj.login("786","786","42005");

//I print that in a task activity 
Entity followup = new Entity("task");

followup["subject"] = "The Phone number of the Customer: "+phone1;
followup["description"] ="The Web Response of The Service: " +webResponse;

The Exception which RequestHandler returns is

System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.HttpWebRequest.CheckConnectPermission(Uri uri, Boolean needExecutionContext)
at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at Microsoft.Crm.Sdk.Samples.RequestHandler.login(String agentId, String password, String extension)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Net.WebPermission
The Zone of the assembly that failed was:
MyComputer

The snapshot of Activity Task in CRM 

Figure 1.0

Is there any way of getting the permission so I can send request,

if its not possible that way then is there any alternative way of doing this?

Thanks, 

*This post is locked for comments

I have the same question (0)
  • Guido Preite Profile Picture
    54,086 Moderator on at

    the plugin is registered inside the sandbox or outside?

    the server you are calling is an url or an ip address?

  • Community Member Profile Picture
    on at

    it is registered in sandbox

    its a server ip with some parameters like

    "http://192.168.200.157/server/api/User/76"


  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    sandboxed plugins can't access to IP addresses.

    msdn.microsoft.com/.../gg334752.aspx

    register the plugin outside sandbox (if you are onpremise) or call the webservice by it's server name

  • Suggested answer
    firestorm Profile Picture
    10 on at

    You cannot use an ip address in the sandbox

    http://msdn.microsoft.com/en-gb/library/gg334752.aspx

    Set up the url you want to access using dns, or remove it from the sandbox.

  • Community Member Profile Picture
    on at

    Guido Preite Thank You :) 
    Registering the plugin as none instead of sandbox did the job,

    but can you explain the reason Why sandbox and out of sandbox? does this ?

  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    Sandbox exists for security reasons.

    CRM Online supports only sandboxed plugins, so if later your CRM will migrate to online or you develop for online you need to keep in mind these limitations.

  • Swaroop Deshmukh Profile Picture
    280 on at

    Hi Guido,

    What is the alternative to use HttpWebRequest for CRM online instance?

    Thanks,

    Swaroop

  • Thomas L Profile Picture
    on at

    Hi Swaroop Deshmukh,

    Did you find an alternative way to solve this issue? (I am also not able to execute a WebRequest in a CRM 2015 Online environment)

  • Community Member Profile Picture
    on at

    "if the plugin is registered in sandbox it can't access to IP addresses, msdn.microsoft.com/.../gg334752.aspx

    register the plugin outside sandbox (if you are onpremise) or call the webservice by it's server name"

    That helped me

  • Thomas L Profile Picture
    on at

    I have to use the sandbox plugin type because I am on CRM 2015 Online.

    Already using the server name, but no luck...

    Other suggestions?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans