ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

C#

Essay by   •  February 2, 2011  •  Study Guide  •  933 Words (4 Pages)  •  1,150 Views

Essay Preview: C#

Report this essay
Page 1 of 4

using System;

using System.Collections.Generic;

using System.Text;

using System.Net;

using System.IO;

using System.Security.Cryptography.X509Certificates;

using System.Net.Security;

namespace LeadPostSSL

{

class Program

{

static void Main(string[] args)

{

// Set username/password

NetworkCredential myCredentials = new NetworkCredential("", "");

myCredentials.UserName = "test";

myCredentials.Password = "test";

// Create a request using a URL that can receive a post.

WebRequest request = WebRequest.Create("https://web.test.com:8889/invoke/Rol/postLead");

// Set the credential

request.Credentials = myCredentials;

// Set the Method and Timeout property of the request to POST.

request.Method = "POST";

request.Timeout = 100000;

// Set certificate overwrite for .NET 1.1 framework. Force accept the cetificate. Enable if Net 1.1

ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();

// Set certificate overwrite for .NET 2.0 framework. Force accept the cetificate using new delegate. Enable if Net 2.0

//ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors){ return true; };

// Create POST data and convert it to a byte array.

byte[] byteArray = Encoding.UTF8.GetBytes(postData);

// Set the ContentType property of the WebRequest.

request.ContentType = "application/x-www-form-urlencoded";

// Set the ContentLength property of the WebRequest.

request.ContentLength = byteArray.Length;

// Get the request stream.

Stream dataStream = request.GetRequestStream();

// Write the data to the request stream.

dataStream.Write(byteArray, 0, byteArray.Length);

// Close the Stream object.

dataStream.Close();

...

...

Download as:   txt (3.4 Kb)   pdf (66 Kb)   docx (10.1 Kb)  
Continue for 3 more pages »
Only available on ReviewEssays.com