Skip to content

Commit a607a90

Browse files
authored
Merge pull request #106499 from erhopf/face-mar-csharp-patch
[CogSvcs] Fix for TLS 1.2 on Win7
2 parents 022911d + 058b969 commit a607a90

File tree

1 file changed

+8
-3
lines changed
  • articles/cognitive-services/Face/QuickStarts

1 file changed

+8
-3
lines changed

articles/cognitive-services/Face/QuickStarts/CSharp.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ms.author: pafarley
1818

1919
In this quickstart, you will use the Azure Face REST API with C# to detect human faces in an image.
2020

21-
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
21+
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2222

2323
## Prerequisites
2424

@@ -27,7 +27,7 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2727

2828
## Create the Visual Studio project
2929

30-
1. In Visual Studio, create a new **Console app (.NET Framework)** project and name it **FaceDetection**.
30+
1. In Visual Studio, create a new **Console app (.NET Framework)** project and name it **FaceDetection**.
3131
1. If there are other projects in your solution, select this one as the single startup project.
3232

3333
## Add face detection code
@@ -41,6 +41,7 @@ Add the following `using` statements to the top of your *Program.cs* file.
4141
```csharp
4242
using System;
4343
using System.IO;
44+
using System.Net;
4445
using System.Net.Http;
4546
using System.Net.Http.Headers;
4647
using System.Text;
@@ -60,7 +61,7 @@ namespace DetectFace
6061

6162
// Replace <Subscription Key> with your valid subscription key.
6263
const string subscriptionKey = "<Subscription Key>";
63-
64+
6465
// replace <myresourcename> with the string found in your endpoint URL
6566
const string uriBase =
6667
"https://<myresourcename>.cognitive.microsoft.com/face/v1.0/detect";
@@ -74,6 +75,10 @@ Add the following code to the **Main** method of the **Program** class. This cod
7475
static void Main(string[] args)
7576
{
7677

78+
// Explicitly set TLS 1.2.
79+
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol |
80+
SecurityProtocolType.Tls12;
81+
7782
// Get the path and filename to process from the user.
7883
Console.WriteLine("Detect faces:");
7984
Console.Write(

0 commit comments

Comments
 (0)