Errors while using external .Net assemblies: The type or namespace name 'HttpWebRequest' could not be found

Symptoms

When using external .Net assemblies, the customer may receive the following issues if trying to use the classes related to the Web requests:

  • The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)
  • The name 'WebRequest' does not exist in the current context.

Resolution

In case the abovementioned types of errors are present when trying to save and run the script, please pass the namespace which includes the HttpWebRequest class into the script module.

The actual namespace for the HttpWebRequest  is System.Net, so in the code it should be included as follows:

using System.Net;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");


 
Additionally, make sure the necessary assembly is added on the .Net Reference tab:

 
If it is not available, please add it using the Add… button and inserting the following string reference:

System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Additional information

External assemblies 


 

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.