Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void Connect(String server, String message)
// combination.
Int32 port = 13000;

// Prefer using declaration to ensure the instance is Disposed later.
// Prefer a using declaration to ensure the instance is Disposed later.
using TcpClient client = new TcpClient(server, port);

// Translate the passed message into ASCII and store it as a Byte array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ public static void Main()
stream.Write(msg, 0, msg.Length);
Console.WriteLine("Sent: {0}", data);
}

// Shutdown and end the connection
client.Close();
}
}
catch(SocketException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ The changed Version and the 'Version' of the response object are displayed.

class HttpVersion_Version10
{
public static void Main()
{
try
{
// <Snippet1>
// HttpClient lifecycle management best practices:
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
HttpClient client = new HttpClient();
public static void Main()
{
try
{
// <Snippet1>
// HttpClient lifecycle management best practices:
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
using HttpClient client = new HttpClient();

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com");
Console.WriteLine("Default HTTP request version is {0}", request.Version);
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com");
Console.WriteLine("Default HTTP request version is {0}", request.Version);

request.Version = HttpVersion.Version10;
Console.WriteLine("Request version after assignment is {0}", request.Version);
request.Version = HttpVersion.Version10;
Console.WriteLine("Request version after assignment is {0}", request.Version);

HttpResponseMessage response = client.Send(request);
Console.WriteLine("Response HTTP version {0}", response.Version);
// </Snippet1>
Console.WriteLine("\nPress 'Enter' Key to Continue..............");
Console.Read();
}
catch(HttpRequestException e)
{
Console.WriteLine("HttpRequestException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
Console.WriteLine("Source :{0} ",e.Source);
}
catch(Exception e)
{
Console.WriteLine("Exception Caught!");
Console.WriteLine("Source :{0}" , e.Source);
Console.WriteLine("Message :{0}" , e.Message);
}
}
using HttpResponseMessage response = client.Send(request);
Console.WriteLine("Response HTTP version {0}", response.Version);
// </Snippet1>
Console.WriteLine("\nPress 'Enter' Key to Continue..............");
Console.Read();
}
catch (HttpRequestException e)
{
Console.WriteLine("HttpRequestException Caught!");
Console.WriteLine("Message :{0} ", e.Message);
Console.WriteLine("Source :{0} ", e.Source);
}
catch (Exception e)
{
Console.WriteLine("Exception Caught!");
Console.WriteLine("Source :{0}", e.Source);
Console.WriteLine("Message :{0}", e.Message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ Class HttpVersion_Version10
' <Snippet1>
' HttpClient lifecycle management best practices:
' https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
Dim client As New HttpClient()
Using client As New HttpClient()
Using request As New HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com")
Console.WriteLine("Default HTTP request version is {0}", request.Version)

Dim request As New HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com")
Console.WriteLine("Default HTTP request version is {0}", request.Version)
request.Version = HttpVersion.Version10
Console.WriteLine("Request version after assignment is {0}", request.Version)

request.Version = HttpVersion.Version10
Console.WriteLine("Request version after assignment is {0}", request.Version)

Dim response As HttpResponseMessage = client.Send(request)
Console.WriteLine("Response HTTP version {0}", response.Version)
Using response As HttpResponseMessage = client.Send(request)
Console.WriteLine("Response HTTP version {0}", response.Version)
End Using
End Using
End Using
' </Snippet1>
Console.WriteLine(ControlChars.Cr + "Press 'Enter' Key to Continue..............")
Console.Read()
Expand Down
4 changes: 2 additions & 2 deletions xml/System.Net.Http/ByteArrayContent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<format type="text/markdown"><![CDATA[

## Remarks
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until the content is sent.
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until after the content is sent.

]]></format>
</remarks>
Expand Down Expand Up @@ -129,7 +129,7 @@ The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the p
<format type="text/markdown"><![CDATA[

## Remarks
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until the content is sent.
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until after the content is sent.

Only the range specified by the `offset` parameter and the `count` parameter is used as content.

Expand Down
5 changes: 1 addition & 4 deletions xml/System.Net.NetworkInformation/Ping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1775,10 +1775,7 @@
<format type="text/markdown"><![CDATA[

## Remarks
These methods do not cause your application's main thread to block. If you want to block while waiting for the ICMP echo reply message, use the <xref:System.Net.NetworkInformation.Ping.Send%2A> methods.

> [!NOTE]
> The IP address returned by any of the <xref:System.Net.NetworkInformation.Ping.SendPingAsync%2A> methods can originate from a malicious remote computer. Do not connect to the remote computer using this. Use DNS to determine the IP address of the machine to which you want to connect.
The IP address returned by any of the <xref:System.Net.NetworkInformation.Ping.SendPingAsync%2A> methods can originate from a malicious remote computer. Do not connect to the remote computer using this. Use DNS to determine the IP address of the machine to which you want to connect.

]]></format>
</remarks>
Expand Down
6 changes: 4 additions & 2 deletions xml/System.Net/WebProxy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@


## Examples
The following code example sets up <xref:System.Net.Http.HttpClient> instance with a <xref:System.Net.WebProxy> instance. The <xref:System.Net.Http.HttpClient> instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the <xref:System.Net.IWebProxyScript> class.)
The following code example sets up an <xref:System.Net.Http.HttpClient> instance with a <xref:System.Net.WebProxy> instance. The <xref:System.Net.Http.HttpClient> instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the <xref:System.Net.IWebProxyScript> class.)

:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Overview/source.cs" id="Snippet1":::
Expand Down Expand Up @@ -1147,7 +1147,8 @@

Applications should use the <xref:System.Net.Http.HttpClient.DefaultProxy?displayProperty=nameWithType> property instead of the <xref:System.Net.WebProxy.GetDefaultProxy%2A> method.


> [!NOTE]
> This property is not supported on .NET Core.

## Examples
The following code example demonstrates calling this method.
Expand All @@ -1157,6 +1158,7 @@

]]></format>
</remarks>
<exception cref="T:System.PlatformNotSupportedException">On .NET Core.</exception>
</Docs>
</Member>
<Member MemberName="GetObjectData">
Expand Down