commit
532a323f99
|
@ -102,7 +102,7 @@ The following code sends a GET request for a product:
|
|||
|
||||
[!code-csharp[Main](calling-a-web-api-from-a-net-client/sample/client/Program.cs?name=snippet_GetProductAsync)]
|
||||
|
||||
The **GetAsync** method sends the HTTP GET request. When the method completes, it returns an **HttpResponseMessage** that contains the HTTP response. If the status code in the response is a success code, the response body contains the JSON representation of a product. Call **ReadAsAsync** to deserialize the JSON payload to a `Product` instance. The **ReadAsync** method is asynchronous because the response body can be arbitrarily large.
|
||||
The **GetAsync** method sends the HTTP GET request. When the method completes, it returns an **HttpResponseMessage** that contains the HTTP response. If the status code in the response is a success code, the response body contains the JSON representation of a product. Call **ReadAsAsync** to deserialize the JSON payload to a `Product` instance. The **ReadAsAsync** method is asynchronous because the response body can be arbitrarily large.
|
||||
|
||||
**HttpClient** does not throw an exception when the HTTP response contains an error code. Instead, the **IsSuccessStatusCode** property is **false** if the status is an error code. If you prefer to treat HTTP error codes as exceptions, call [HttpResponseMessage.EnsureSuccessStatusCode](https://msdn.microsoft.com/en-us/library/system.net.http.httpresponsemessage.ensuresuccessstatuscode(v=vs.110).aspx) on the response object. `EnsureSuccessStatusCode` throws an exception if the status code falls outside the range 200–299. Note that **HttpClient** can throw exceptions for other reasons — for example, if the request times out.
|
||||
|
||||
|
@ -111,7 +111,7 @@ The **GetAsync** method sends the HTTP GET request. When the method completes, i
|
|||
|
||||
When **ReadAsAsync** is called with no parameters, it uses a default set of *media formatters* to read the response body. The default formatters support JSON, XML, and Form-url-encoded data.
|
||||
|
||||
Instead of using the default formatters, you can provide a list of formatters to the **ReadAsync** method. Using a a list of formatters is useful if you have a custom media-type formatter:
|
||||
Instead of using the default formatters, you can provide a list of formatters to the **ReadAsAsync** method. Using a a list of formatters is useful if you have a custom media-type formatter:
|
||||
|
||||
```csharp
|
||||
var formatters = new List<MediaTypeFormatter>() {
|
||||
|
|
|
@ -73,7 +73,7 @@ Run the app and navigate to the About view to verify the font-awesome package wo
|
|||
|
||||
## Exploring the client-side build process
|
||||
|
||||
Most ASP.NET Core project templates are already configured to use Bower. This next walkthrough starts with an empty ASP.NET Core project and adds each piece manually, so you can get a feel for how Bower is used in a project. You see can what happens to the project structure and the runtime output as each configuration change is made.
|
||||
Most ASP.NET Core project templates are already configured to use Bower. This next walkthrough starts with an empty ASP.NET Core project and adds each piece manually, so you can get a feel for how Bower is used in a project. You can see what happens to the project structure and the runtime output as each configuration change is made.
|
||||
|
||||
The general steps to use the client-side build process with Bower are:
|
||||
|
||||
|
|
Loading…
Reference in New Issue