954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

httpS &SSL

can any one explain when and how we can use https and ssL IN c# .net..what is the use for it?

sivak
Junior Poster
132 posts since Nov 2008
Reputation Points: 3
Solved Threads: 0
 

You use https:// in C# whenever you are accessing an https:// website. I don't really know of another way to answer that question. SSL is handled under the hood for the most part by the framework so you don't have to worry about it.

Here is an example of an https:// post to an online merchant:

public void Post()
    {
      string args = GetPostUrlArgs();
      string result = string.Empty;

      HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(@"https://secure.authorize.net/gateway/transact.dll");
      objRequest.Method = "POST";
      objRequest.ContentLength = args.Length;
      objRequest.ContentType = "application/x-www-form-urlencoded";

      StreamWriter myWriter = null;
      try
      {
        myWriter = new StreamWriter(objRequest.GetRequestStream());
        myWriter.Write(args);
      }
      finally
      {
        myWriter.Close();
        myWriter.Dispose();
      }

      HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
      using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
      {
        result = sr.ReadToEnd();
        sr.Close();
        sr.Dispose();
      }

      this.Response = new CcTxResponse(result);
    }
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

There is nothing to do with https and SSL. in C#. All these are server side stuffs. If any domain is installed with SSL certification then that domain can be accessed by https. You need to have dedicated IP address for that website and that website needs to have SSL certificate installed within the IIS.

thewebhostingdi
Junior Poster
168 posts since Jun 2009
Reputation Points: 3
Solved Threads: 14
 
There is nothing to do with https and SSL. in C#. All these are server side stuffs. If any domain is installed with SSL certification then that domain can be accessed by https. You need to have dedicated IP address for that website and that website needs to have SSL certificate installed within the IIS.

Please stop burning up the forum with useless posts, and in this case incorrect information. SSL extends beyond https. SSL/Secure Socket Layer allows you to create a secure socket between any two endpoints and https:// being one implementation of it.

C# Has plenty of types related to SSL:
System.Security.Cryptography.X509Certificates
System.Net.Security.SslStream

There are more, take a look at the help file.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You