0

I have created a farm solutions to access external webservice an created a webpart. After deployed the solution it works fine. Then requirement has been changed. So I changed the application to sandboxed, it endsup with error. I debug the code and it returns an exception.

Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. This is my code where exception was thrown.

 WebRequest req = WebRequest.Create(@"https://URL");

In my sharepoint site I find the below error in webpart.

Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.

0

Sandbox is an isolated environment that do not allow you to call anything outside that environment. A call through a web url away is a call outside the sandbox, requiring System.Net.WebPermissions. This is prohibited by the Code Access Security policies defined for the Sandbox.

You have 2 options here.

  1. Use JavaScript Client Object Model
  2. Build a Sandbox Proxy solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.