From 4d08d27c2c8a3734ed84fa8f28b4f26e3e562976 Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Wed, 29 Nov 2017 11:54:07 -1000 Subject: [PATCH 01/11] Update calling-a-web-api-from-a-net-client.md --- .../overview/advanced/calling-a-web-api-from-a-net-client.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client.md b/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client.md index 12fa6bc8b2c4..e5ce442d4da6 100644 --- a/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client.md +++ b/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client.md @@ -162,7 +162,7 @@ Like GET, a DELETE request does not have a request body. You don't need to speci To test the client app: -1. [Download](https://github.com/aspnet/Docs/tree/master/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client/samples/server) and run the server app. [Download instructions](xref:tutorials/index#how-to-download-a-sample). Verify the server app is working. For exaxmple, `http://localhost:64195/api/products` should return a list of products. +1. [Download](https://github.com/aspnet/Docs/tree/master/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client/samples/server) and run the server app. [Download instructions](https://docs.microsoft.com/en-us/aspnet/core/tutorials/#how-to-download-a-sample). Verify the server app is working. For exaxmple, `http://localhost:64195/api/products` should return a list of products. 2. Set the base URI for HTTP requests. Change the port number to the port used in the server app. [!code-csharp[Main](calling-a-web-api-from-a-net-client/sample/client/Program.cs?name=snippet5&highlight=2)] @@ -174,4 +174,4 @@ Name: Gizmo Price: 100.0 Category: Widgets Updating price... Name: Gizmo Price: 80.0 Category: Widgets Deleted (HTTP Status = 204) -``` \ No newline at end of file +``` From 737ef9bdb0766d436e227385b39e191c1c092f0b Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Wed, 29 Nov 2017 11:55:06 -1000 Subject: [PATCH 02/11] Update index.md (#4893) --- aspnetcore/tutorials/first-mvc-app/index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aspnetcore/tutorials/first-mvc-app/index.md b/aspnetcore/tutorials/first-mvc-app/index.md index 92b58f245bf8..944cabf8a411 100644 --- a/aspnetcore/tutorials/first-mvc-app/index.md +++ b/aspnetcore/tutorials/first-mvc-app/index.md @@ -15,6 +15,11 @@ uid: tutorials/first-mvc-app/index [!INCLUDE[consider RP](../../includes/razor.md)] +There are 3 versions of this tutorial: + +* Windows: This series +* macOS: [Create an ASP.NET Core MVC app with Visual Studio for Mac](xref:tutorials/first-mvc-app-mac/start-mvc) +* macOS, Linux, and Windows: [Create an ASP.NET Core MVC app with Visual Studio Code](xref:tutorials/first-mvc-app-xplat/start-mvc) The tutorial series includes the following: 1. [Getting started](start-mvc.md) From 604f717e29c9f048410c849c05280dc633351fa7 Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Wed, 29 Nov 2017 11:55:28 -1000 Subject: [PATCH 03/11] landing page for indiv user accounts (#4883) * landing page for indiv user accounts * work * work * work * fix --- aspnetcore/security/authentication/index.md | 2 ++ .../security/authentication/individual.md | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 aspnetcore/security/authentication/individual.md diff --git a/aspnetcore/security/authentication/index.md b/aspnetcore/security/authentication/index.md index 72d4d52acb3c..31687cc080c3 100644 --- a/aspnetcore/security/authentication/index.md +++ b/aspnetcore/security/authentication/index.md @@ -41,3 +41,5 @@ uid: security/authentication/index * [Securing ASP.NET Core apps with IdentityServer4](http://docs.identityserver.io/en/release/) * [Securing ASP.NET Core apps with Azure App Service Authentication (Easy Auth)](https://docs.microsoft.com/azure/app-service/app-service-authentication-overview) + +* [Articles based on projects created with individual user accounts](xref:security/authentication/individual) \ No newline at end of file diff --git a/aspnetcore/security/authentication/individual.md b/aspnetcore/security/authentication/individual.md new file mode 100644 index 000000000000..7d5c9de88018 --- /dev/null +++ b/aspnetcore/security/authentication/individual.md @@ -0,0 +1,30 @@ +--- +title: Articles based on projects created with individual user accounts +author: rick-anderson +description: This document lists articles based on projects created with individual user accounts. +keywords: ASP.NET Core,authorization,IAuthorizationService +ms.author: riande +manager: wpickett +ms.date: 11/30/2017 +ms.topic: article +ms.technology: aspnet +ms.prod: asp.net-core +uid: security/authentication/individual +--- +# Articles based on projects created with individual user accounts + +ASP.NET Core Identity is included in project templates in Visual Studio with the "Individual User Accounts" option. + +The authentication templates are available in .NET Core CLI with `-au Individual`: + +```console +dotnet new mvc -au Individual +dotnet new webapi -au Individual +dotnet new razor -au Individual +``` + +The following articles show how to use the code generated in ASP.NET Core templates that use individual user accounts: + +* [Two-factor authentication with SMS](xref:security/authentication/2fa) +* [Account confirmation and password recovery in ASP.NET Core](xref:security/authentication/accconfirm) +* [Create an ASP.NET Core app with user data protected by authorization](xref:security/authorization/secure-data) \ No newline at end of file From 4b11174d8ca6b6ebe866a0367f7c8367ae5d9c79 Mon Sep 17 00:00:00 2001 From: Michael DePouw Date: Wed, 29 Nov 2017 17:01:14 -0500 Subject: [PATCH 04/11] add comma (#4894) --- aspnetcore/security/authorization/policies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/security/authorization/policies.md b/aspnetcore/security/authorization/policies.md index c9b273fa04ba..d8782ccb3231 100644 --- a/aspnetcore/security/authorization/policies.md +++ b/aspnetcore/security/authorization/policies.md @@ -144,7 +144,7 @@ You can see in our [handler example](policies.md#security-authorization-handler- * To guarantee failure even if other handlers for a requirement succeed, call `context.Fail`. -Regardless of what you call inside your handler all handlers for a requirement will be called when a policy requires the requirement. This allows requirements to have side effects, such as logging, which will always take place even if `context.Fail()` has been called in another handler. +Regardless of what you call inside your handler, all handlers for a requirement will be called when a policy requires the requirement. This allows requirements to have side effects, such as logging, which will always take place even if `context.Fail()` has been called in another handler. From f0503ecb294482011c7cef845ee144c6c718d4de Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Wed, 29 Nov 2017 17:25:23 -0600 Subject: [PATCH 05/11] Catch a more general exception and report it (#4895) --- .../sample/RazorPagesMovie/Utilities/FileHelpers.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs b/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs index 4fdc338eae0a..ac00824d9a20 100644 --- a/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs +++ b/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel.DataAnnotations; using System.IO; using System.Net; @@ -76,9 +77,9 @@ public static async Task ProcessFormFile(IFormFile formFile, ModelStateD } } } - catch (IOException ex) + catch (Exception ex) { - modelState.AddModelError(formFile.Name, $"The {fieldDisplayName}file ({fileName}) upload failed. Please contact the Help Desk for support."); + modelState.AddModelError(formFile.Name, $"The {fieldDisplayName}file ({fileName}) upload failed. Please contact the Help Desk for support. Error: {ex.Message}"); // Log the exception } } From b0573ef0c69627f3a81554c659a7760f247e2018 Mon Sep 17 00:00:00 2001 From: Sadegh-Ameri Date: Thu, 30 Nov 2017 23:51:12 +0800 Subject: [PATCH 06/11] Missing ContentPlaceHolder in master page (#4898) --- .../using-web-api-with-aspnet-web-forms/samples/sample8.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample8.html diff --git a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample8.html b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample8.html new file mode 100644 index 000000000000..b0340b92ffc8 --- /dev/null +++ b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample8.html @@ -0,0 +1 @@ + From b183405f5450a7b1d850b36409b1e065d05f768c Mon Sep 17 00:00:00 2001 From: Sadegh-Ameri Date: Fri, 1 Dec 2017 00:19:58 +0800 Subject: [PATCH 07/11] Missing ContentPlaceHolder in master page (#4899) * Missing ContentPlaceHolder in master page * Minor edits * Relocate paragraph * More tweaks --- .../using-web-api-with-aspnet-web-forms.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms.md b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms.md index c71a2339c21a..809949c65afa 100644 --- a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms.md +++ b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms.md @@ -76,6 +76,10 @@ For more information about routing tables, see [Routing in ASP.NET Web API](../w That's all you need to create a web API that clients can access. Now let's add an HTML page that uses jQuery to call the API. +Make sure your master page (for example, *Site.Master*) includes a `ContentPlaceHolder` with `ID="HeadContent"`: + +[!code-html[Main](using-web-api-with-aspnet-web-forms/samples/sample8.html)] + Open the file Default.aspx. Replace the boilerplate text that is in the main content section, as shown: [!code-aspx[Main](using-web-api-with-aspnet-web-forms/samples/sample5.aspx)] From ea30d6245f02da61c63349f73688a9d96d9259b7 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Thu, 30 Nov 2017 13:04:53 -0600 Subject: [PATCH 08/11] Remove double-spaces (#4901) --- aspnetcore/fundamentals/logging/index.md | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/aspnetcore/fundamentals/logging/index.md b/aspnetcore/fundamentals/logging/index.md index 7febad8d238c..39c4ced8edcb 100644 --- a/aspnetcore/fundamentals/logging/index.md +++ b/aspnetcore/fundamentals/logging/index.md @@ -37,9 +37,9 @@ Then call logging methods on that logger object: [!code-csharp[](index/sample/Controllers/TodoController.cs?name=snippet_CallLogMethods&highlight=3,7)] -This example creates logs with the `TodoController` class as the *category*. Categories are explained [later in this article](#log-category). +This example creates logs with the `TodoController` class as the *category*. Categories are explained [later in this article](#log-category). -ASP.NET Core does not provide async logger methods because logging should be so fast that it isn't worth the cost of using async. If you're in a situation where that's not true, consider changing the way you log. If your data store is slow, write the log messages to a fast store first, then move them to a slow store later. For example, log to a message queue that is read and persisted to slow storage by another process. +ASP.NET Core does not provide async logger methods because logging should be so fast that it isn't worth the cost of using async. If you're in a situation where that's not true, consider changing the way you log. If your data store is slow, write the log messages to a fast store first, then move them to a slow store later. For example, log to a message queue that is read and persisted to slow storage by another process. ## How to add providers @@ -117,13 +117,13 @@ The `ILogger` and `ILoggerFactory` interfaces are in [Microsoft.Extensions.Loggi ## Log category -A *category* is included with each log that you create. You specify the category when you create an `ILogger` object. The category may be any string, but a convention is to use the fully qualified name of the class from which the logs are written. For example: "TodoApi.Controllers.TodoController". +A *category* is included with each log that you create. You specify the category when you create an `ILogger` object. The category may be any string, but a convention is to use the fully qualified name of the class from which the logs are written. For example: "TodoApi.Controllers.TodoController". You can specify the category as a string or use an extension method that derives the category from the type. To specify the category as a string, call `CreateLogger` on an `ILoggerFactory` instance, as shown below. [!code-csharp[](index/sample//Controllers/TodoController.cs?name=snippet_CreateLogger&highlight=7,10)] -Most of the time, it will be easier to use `ILogger`, as in the following example. +Most of the time, it will be easier to use `ILogger`, as in the following example. [!code-csharp[](index/sample//Controllers/TodoController.cs?name=snippet_LoggerDI&highlight=7)] @@ -208,7 +208,7 @@ Each time you write a log, you can specify an *event ID*. The sample app does th An event ID is an integer value that you can use to associate a set of logged events with one another. For instance, a log for adding an item to a shopping cart could be event ID 1000 and a log for completing a purchase could be event ID 1001. -In logging output, the event ID may be stored in a field or included in the text message, depending on the provider. The Debug provider doesn't show event IDs, but the console provider shows them in brackets after the category: +In logging output, the event ID may be stored in a field or included in the text message, depending on the provider. The Debug provider doesn't show event IDs, but the console provider shows them in brackets after the category: ```console info: TodoApi.Controllers.TodoController[1002] @@ -264,7 +264,7 @@ System.Exception: Item not found exception. # [ASP.NET Core 2.x](#tab/aspnetcore2x) -You can specify a minimum log level for a specific provider and category or for all providers or all categories. Any logs below the minimum level aren't passed to that provider, so they don't get displayed or stored. +You can specify a minimum log level for a specific provider and category or for all providers or all categories. Any logs below the minimum level aren't passed to that provider, so they don't get displayed or stored. If you want to suppress all logs, you can specify `LogLevel.None` as the minimum log level. The integer value of `LogLevel.None` is 6, which is higher than `LogLevel.Critical` (5). @@ -292,22 +292,22 @@ The second `AddFilter` specifies the Debug provider by using its type name. The The configuration data and the `AddFilter` code shown in the preceding examples create the rules shown in the following table. The first six come from the configuration example and the last two come from the code example. -Number|Provider|Categories that begin with|Minimum log level| -------|--------|--------------------------|-----------------| -1|Debug|All categories|Information| -2|Console|Microsoft.AspNetCore.Mvc.Razor.Internal|Warning| -3|Console|Microsoft.AspNetCore.Mvc.Razor.Razor|Debug| -4|Console|Microsoft.AspNetCore.Mvc.Razor|Error| -5|Console|All categories|Information| -6|All providers|All categories|Debug -7|All providers|System|Debug -8|Debug|Microsoft|Trace +| Number | Provider | Categories that begin with ... | Minimum log level | +| :----: | ------------- | --------------------------------------- | ----------------- | +| 1 | Debug | All categories | Information | +| 2 | Console | Microsoft.AspNetCore.Mvc.Razor.Internal | Warning | +| 3 | Console | Microsoft.AspNetCore.Mvc.Razor.Razor | Debug | +| 4 | Console | Microsoft.AspNetCore.Mvc.Razor | Error | +| 5 | Console | All categories | Information | +| 6 | All providers | All categories | Debug | +| 7 | All providers | System | Debug | +| 8 | Debug | Microsoft | Trace | When you create an `ILogger` object to write logs with, the `ILoggerFactory` object selects a single rule per provider to apply to that logger. All messages written by that `ILogger` object are filtered based on the selected rules. The most specific rule possible for each provider and category pair is selected from the available rules. The following algorithm is used for each provider when an `ILogger` is created for a given category: -* Select all rules that match the provider or its alias. If none are found, select all rules with an empty provider. +* Select all rules that match the provider or its alias. If none are found, select all rules with an empty provider. * From the result of the preceding step, select rules with longest matching category prefix. If none are found, select all rules that don't specify a category. * If multiple rules are selected take the **last** one. * If no rules are selected, use `MinimumLevel`. @@ -352,7 +352,7 @@ The `AddConsole` and `AddDebug` extension methods provide overloads that let you [!code-csharp[](index/sample/Startup.cs?name=snippet_AddConsoleAndDebugWithFilter&highlight=6-7)] -The `AddEventLog` method has an overload that takes an `EventLogSettings` instance, which may contain a filtering function in its `Filter` property. The TraceSource provider does not provide any of those overloads, since its logging level and other parameters are based on the `SourceSwitch` and `TraceListener` it uses. +The `AddEventLog` method has an overload that takes an `EventLogSettings` instance, which may contain a filtering function in its `Filter` property. The TraceSource provider does not provide any of those overloads, since its logging level and other parameters are based on the `SourceSwitch` and `TraceListener` it uses. You can set filtering rules for all providers that are registered with an `ILoggerFactory` instance by using the `WithFilter` extension method. The example below limits framework logs (category begins with "Microsoft" or "System") to warnings while letting the app log at debug level. @@ -366,7 +366,7 @@ The `WithFilter` extension method is provided by the [Microsoft.Extensions.Loggi ## Log scopes -You can group a set of logical operations within a *scope* in order to attach the same data to each log that is created as part of that set. For example, you might want every log created as part of processing a transaction to include the transaction ID. +You can group a set of logical operations within a *scope* in order to attach the same data to each log that is created as part of that set. For example, you might want every log created as part of processing a transaction to include the transaction ID. A scope is an `IDisposable` type that is returned by the `ILogger.BeginScope` method and lasts until it is disposed. You use a scope by wrapping your logger calls in a `using` block, as shown here: @@ -430,7 +430,7 @@ logging.AddConsole() loggerFactory.AddConsole() ``` -[AddConsole overloads](https://docs.microsoft.com/aspnet/core/api/microsoft.extensions.logging.consoleloggerextensions) let you pass in an a minimum log level, a filter function, and a boolean that indicates whether scopes are supported. Another option is to pass in an `IConfiguration` object, which can specify scopes support and logging levels. +[AddConsole overloads](https://docs.microsoft.com/aspnet/core/api/microsoft.extensions.logging.consoleloggerextensions) let you pass in an a minimum log level, a filter function, and a boolean that indicates whether scopes are supported. Another option is to pass in an `IConfiguration` object, which can specify scopes support and logging levels. If you are considering the console provider for use in production, be aware that it has a significant impact on performance. @@ -582,7 +582,7 @@ The [Microsoft.Extensions.Logging.AzureAppServices](https://www.nuget.org/packag # [ASP.NET Core 2.x](#tab/aspnetcore2x) -You don't have to install the provider package or call the `AddAzureWebAppDiagnostics` extension method. The provider is automatically available to your app when you deploy the app to Azure App Service. +You don't have to install the provider package or call the `AddAzureWebAppDiagnostics` extension method. The provider is automatically available to your app when you deploy the app to Azure App Service. # [ASP.NET Core 1.x](#tab/aspnetcore1x) @@ -590,7 +590,7 @@ You don't have to install the provider package or call the `AddAzureWebAppDiagno loggerFactory.AddAzureWebAppDiagnostics(); ``` -An `AddAzureWebAppDiagnostics` overload lets you pass in [AzureAppServicesDiagnosticsSettings](https://github.com/aspnet/Logging/blob/c7d0b1b88668ff4ef8a86ea7d2ebb5ca7f88d3e0/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs) with which you can override default settings such as the logging output template, blob name, and file size limit. (*Output template* is a message template that's applied to all logs on top of the one that you provide when you call an `ILogger` method.) +An `AddAzureWebAppDiagnostics` overload lets you pass in [AzureAppServicesDiagnosticsSettings](https://github.com/aspnet/Logging/blob/c7d0b1b88668ff4ef8a86ea7d2ebb5ca7f88d3e0/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs) with which you can override default settings such as the logging output template, blob name, and file size limit. (*Output template* is a message template that's applied to all logs on top of the one that you provide when you call an `ILogger` method.) --- @@ -600,7 +600,7 @@ When you deploy to an App Service app, your application honors the settings in t The default location for log files is in the *D:\\home\\LogFiles\\Application* folder, and the default file name is *diagnostics-yyyymmdd.txt*. The default file size limit is 10 MB, and the default maximum number of files retained is 2. The default blob name is *{app-name}{timestamp}/yyyy/mm/dd/hh/{guid}-applicationLog.txt*. For more information about default behavior, see [AzureAppServicesDiagnosticsSettings](https://github.com/aspnet/Logging/blob/c7d0b1b88668ff4ef8a86ea7d2ebb5ca7f88d3e0/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs). -The provider only works when your project runs in the Azure environment. It has no effect when you run locally — it does not write to local files or local development storage for blobs. +The provider only works when your project runs in the Azure environment. It has no effect when you run locally — it does not write to local files or local development storage for blobs. ## Third-party logging providers From 54918584919b3771f28ca861bcd1ca7b78ad5ae2 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Thu, 30 Nov 2017 13:05:28 -0600 Subject: [PATCH 09/11] Add a note and break lines in RP tutorial sample (#4900) --- .../RazorPagesMovie/Utilities/FileHelpers.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs b/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs index ac00824d9a20..09eaa1685e3e 100644 --- a/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs +++ b/aspnetcore/tutorials/razor-pages/razor-pages-start/sample/RazorPagesMovie/Utilities/FileHelpers.cs @@ -21,11 +21,13 @@ public static async Task ProcessFormFile(IFormFile formFile, ModelStateD // property associated with this IFormFile. If a display // name isn't found, error messages simply won't show // a display name. - MemberInfo property = typeof(FileUpload).GetProperty(formFile.Name.Substring(formFile.Name.IndexOf(".") + 1)); + MemberInfo property = + typeof(FileUpload).GetProperty(formFile.Name.Substring(formFile.Name.IndexOf(".") + 1)); if (property != null) { - var displayAttribute = property.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute; + var displayAttribute = + property.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute; if (displayAttribute != null) { @@ -41,7 +43,8 @@ public static async Task ProcessFormFile(IFormFile formFile, ModelStateD if (formFile.ContentType.ToLower() != "text/plain") { - modelState.AddModelError(formFile.Name, $"The {fieldDisplayName}file ({fileName}) must be a text file."); + modelState.AddModelError(formFile.Name, + $"The {fieldDisplayName}file ({fileName}) must be a text file."); } // Check the file length and don't bother attempting to @@ -60,7 +63,16 @@ public static async Task ProcessFormFile(IFormFile formFile, ModelStateD { string fileContents; - using (var reader = new StreamReader(formFile.OpenReadStream(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), detectEncodingFromByteOrderMarks: true)) + // The StreamReader is created to read files that are UTF-8 encoded. + // If uploads require some other encoding, provide the encoding in the + // using statement. To change to 32-bit encoding, change + // new UTF8Encoding(...) to new UTF32Encoding(). + using ( + var reader = + new StreamReader( + formFile.OpenReadStream(), + new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), + detectEncodingFromByteOrderMarks: true)) { fileContents = await reader.ReadToEndAsync(); @@ -73,13 +85,16 @@ public static async Task ProcessFormFile(IFormFile formFile, ModelStateD } else { - modelState.AddModelError(formFile.Name, $"The {fieldDisplayName}file ({fileName}) is empty."); + modelState.AddModelError(formFile.Name, + $"The {fieldDisplayName}file ({fileName}) is empty."); } } } catch (Exception ex) { - modelState.AddModelError(formFile.Name, $"The {fieldDisplayName}file ({fileName}) upload failed. Please contact the Help Desk for support. Error: {ex.Message}"); + modelState.AddModelError(formFile.Name, + $"The {fieldDisplayName}file ({fileName}) upload failed. " + + $"Please contact the Help Desk for support. Error: {ex.Message}"); // Log the exception } } From ac0d7c22451f45b8b18e0cbe52a736946a8462a8 Mon Sep 17 00:00:00 2001 From: Sadegh-Ameri Date: Fri, 1 Dec 2017 03:53:05 +0800 Subject: [PATCH 10/11] Changed text to html (#4897) I'm using jquery-1.10.2.min.js --- .../using-web-api-with-aspnet-web-forms/samples/sample7.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample7.html b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample7.html index 7d29540e513f..1a89ad25d4a6 100644 --- a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample7.html +++ b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample7.html @@ -8,11 +8,11 @@ $.each(data, function (key, val) { // Add a table row for the product. var row = '' + val.Name + '' + val.Price + ''; - $('', { text: row }) // Append the name. + $('', { html: row }) // Append the name. .appendTo($('#products')); }); }); } $(document).ready(getProducts); - \ No newline at end of file + From a3a0a22df4f5687926e7ffb741c6a070e8b9b790 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Thu, 30 Nov 2017 14:01:51 -0600 Subject: [PATCH 11/11] Update jQuery reference to 1.10.2 (#4903) --- .../using-web-api-with-aspnet-web-forms/samples/sample6.aspx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample6.aspx b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample6.aspx index e3f138cf6074..43df1470ff88 100644 --- a/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample6.aspx +++ b/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms/samples/sample6.aspx @@ -1,3 +1,3 @@ - - \ No newline at end of file + +