Skip to content

Commit 3c28600

Browse files
authored
Merge pull request #774 from dotnet/master
Update live with current master
2 parents 1e2dc45 + 568480a commit 3c28600

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/WebRequestGetExample.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ public static void Main()
1313
"http://www.contoso.com/default.html");
1414
// If required by the server, set the credentials.
1515
request.Credentials = CredentialCache.DefaultCredentials;
16+
1617
// Get the response.
1718
WebResponse response = request.GetResponse();
1819
// Display the status.
1920
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
21+
2022
// Get the stream containing content returned by the server.
2123
// The using block ensures the stream is automatically closed.
2224
using (Stream dataStream = response.GetResponseStream())
@@ -28,8 +30,9 @@ public static void Main()
2830
// Display the content.
2931
Console.WriteLine(responseFromServer);
3032
}
33+
3134
// Close the response.
3235
response.Close();
3336
}
3437
}
35-
}
38+
}

snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/WebRequestPostExample.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,28 @@ public static void Main()
1313
WebRequest request = WebRequest.Create("http://www.contoso.com/PostAccepter.aspx ");
1414
// Set the Method property of the request to POST.
1515
request.Method = "POST";
16+
1617
// Create POST data and convert it to a byte array.
1718
string postData = "This is a test that posts this string to a Web server.";
1819
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
20+
1921
// Set the ContentType property of the WebRequest.
2022
request.ContentType = "application/x-www-form-urlencoded";
2123
// Set the ContentLength property of the WebRequest.
2224
request.ContentLength = byteArray.Length;
25+
2326
// Get the request stream.
2427
Stream dataStream = request.GetRequestStream();
2528
// Write the data to the request stream.
2629
dataStream.Write(byteArray, 0, byteArray.Length);
2730
// Close the Stream object.
2831
dataStream.Close();
32+
2933
// Get the response.
3034
WebResponse response = request.GetResponse();
3135
// Display the status.
3236
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
37+
3338
// Get the stream containing content returned by the server.
3439
// The using block ensures the stream is automatically closed.
3540
using (dataStream = response.GetResponseStream())
@@ -41,8 +46,9 @@ public static void Main()
4146
// Display the content.
4247
Console.WriteLine(responseFromServer);
4348
}
49+
4450
// Close the response.
4551
response.Close();
4652
}
4753
}
48-
}
54+
}

snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsNamespace/CS/csrefKeywordsNamespace2.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ public override string ToString()
3434

3535
namespace NameSpace3
3636
{
37-
// Using directive:
38-
using NameSpace1;
39-
// Using directive:
40-
using NameSpace2;
41-
4237
class MainClass
4338
{
4439
static void Main()

snippets/visualbasic/VS_Snippets_Network/RequestDataUsingWebRequest/vb/WebRequestGetExample.vb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ Namespace Examples.System.Net
99
WebRequest.Create("http://www.contoso.com/default.html")
1010
' If required by the server, set the credentials.
1111
request.Credentials = CredentialCache.DefaultCredentials
12+
1213
' Get the response.
1314
Dim response As WebResponse = request.GetResponse()
1415
' Display the status.
1516
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
17+
1618
' Get the stream containing content returned by the server.
1719
' The using block ensures the stream is automatically closed.
1820
Using dataStream As Stream = response.GetResponseStream()
@@ -23,8 +25,9 @@ Namespace Examples.System.Net
2325
' Display the content.
2426
Console.WriteLine(responseFromServer)
2527
End Using
26-
' Clean up the response.
28+
29+
' Clean up the response.
2730
response.Close()
2831
End Sub
2932
End Class
30-
End Namespace
33+
End Namespace

snippets/visualbasic/VS_Snippets_Network/SendDataUsingWebRequest/vb/WebRequestPostExample.vb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@ Namespace Examples.System.Net
99
Dim request As WebRequest = WebRequest.Create("http://www.contoso.com/PostAccepter.aspx ")
1010
' Set the Method property of the request to POST.
1111
request.Method = "POST"
12+
1213
' Create POST data and convert it to a byte array.
1314
Dim postData As String = "This is a test that posts this string to a Web server."
1415
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
16+
1517
' Set the ContentType property of the WebRequest.
1618
request.ContentType = "application/x-www-form-urlencoded"
1719
' Set the ContentLength property of the WebRequest.
1820
request.ContentLength = byteArray.Length
21+
1922
' Get the request stream.
2023
Dim dataStream As Stream = request.GetRequestStream()
2124
' Write the data to the request stream.
2225
dataStream.Write(byteArray, 0, byteArray.Length)
2326
' Close the Stream object.
2427
dataStream.Close()
28+
2529
' Get the response.
2630
Dim response As WebResponse = request.GetResponse()
2731
' Display the status.
2832
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
33+
2934
' Get the stream containing content returned by the server.
3035
' The using block ensures the stream is automatically closed.
3136
Using dataStream1 As Stream = response.GetResponseStream()
@@ -36,8 +41,9 @@ Namespace Examples.System.Net
3641
' Display the content.
3742
Console.WriteLine(responseFromServer)
3843
End Using
44+
3945
' Clean up the response.
4046
response.Close()
4147
End Sub
4248
End Class
43-
End Namespace
49+
End Namespace

0 commit comments

Comments
 (0)