You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/client-side/bundling-and-minification.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ author: wadepickett
4
4
description: Learn how to optimize static resources in an ASP.NET Core web application by applying bundling and minification techniques.
5
5
ms.author: wpickett
6
6
ms.custom: mvc
7
-
ms.date: 03/14/2021
7
+
ms.date: 05/08/2025
8
8
uid: client-side/bundling-and-minification
9
9
---
10
10
# Bundle and minify static assets in ASP.NET Core
@@ -21,11 +21,11 @@ Bundling and minification primarily improve the first page request load time. On
21
21
22
22
### Bundling
23
23
24
-
Bundling combines multiple files into a single file. Bundling reduces the number of server requests that are necessary to render a web asset, such as a web page. You can create any number of individual bundles specifically for CSS, JavaScript, etc. Fewer files mean fewer HTTP requests from the browser to the server or from the service providing your application. This results in improved first page load performance.
24
+
Bundling combines multiple files into a single file. Bundling reduces the number of server requests necessary to render a web asset, such as a web page. You can create any number of individual bundles specifically for CSS, JavaScript, etc. Fewer files mean fewer HTTP requests from the browser to the server or from the service providing your application. This results in improved first page load performance.
25
25
26
26
### Minification
27
27
28
-
Minification removes unnecessary characters from code without altering functionality. The result is a significant size reduction in requested assets (such as CSS, images, and JavaScript files). Common side effects of minification include shortening variable names to one character and removing comments and unnecessary whitespace.
28
+
Minification removes unnecessary characters from code without altering functionality. The result is a significant size reduction in requested assets (such as CSS, images, and JavaScript files). Common effects of minification include shortening variable names to one character and removing comments and unnecessary whitespace.
29
29
30
30
Consider the following JavaScript function:
31
31
@@ -72,9 +72,7 @@ The test app used to generate the figures in the preceding table demonstrates ty
72
72
73
73
## Choose a bundling and minification strategy
74
74
75
-
ASP.NET Core is compatible with WebOptimizer, an open-source bundling and minification solution. For set up instructions and sample projects, see [WebOptimizer](https://github.com/ligershark/WebOptimizer). ASP.NET Core doesn't provide a native bundling and minification solution.
76
-
77
-
Third-party tools, such as [Gulp](https://gulpjs.com) and [Webpack](https://webpack.js.org), provide workflow automation for bundling and minification, as well as linting and image optimization. By using bundling and minification, the minified files are created prior to the app's deployment. Bundling and minifying before deployment provides the advantage of reduced server load. However, it's important to recognize that bundling and minification increases build complexity and only works with static files.
75
+
ASP.NET Core doesn't provide a native bundling and minification solution. Third-party tools, such as [Gulp](https://gulpjs.com) and [Webpack](https://webpack.js.org), provide workflow automation for bundling and minification, as well as linting and image optimization. Bundling and minifying before deployment provides the advantage of reduced server load. However, bundling and minification increase build complexity and only work with static files.
To use `TypedResults`, the return type must be fully declared, which when asynchronousrequires the `Task<>` wrapper. Using `TypedResults` is more verbose, but that's the trade-off for having the type information be statically available and thus capable of self-describing to OpenAPI:
100
+
To use `TypedResults`, the return type must be fully declared; when the method is asynchronous, the declaration requires wrapping the return type in a `Task<>`. Using `TypedResults` is more verbose, but that's the trade-off for having the type information be statically available and thus capable of self-describing to OpenAPI:
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/openapi/using-openapi-documents.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,18 @@ The `Swashbuckle.AspNetCore.SwaggerUi` package provides a bundle of Swagger UI's
25
25
26
26
As a security best practice on limiting information disclosure, ***OpenAPI user interfaces (Swagger UI, ReDoc, Scalar) should only be enabled in development environments.*** For example, see [Swagger OAuth 2.0 configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/).
27
27
28
+
Launch the app and navigate to `https://localhost:<port>/swagger` to view the Swagger UI.
29
+
30
+
To automatically launch the app at the Swagger UI URL using the `https` profile of `Properties/launchSettings.json`:
31
+
32
+
* Confirm that `launchBrowser` is enabled (`true`).
33
+
* Set the `launchUrl` to `swagger`.
34
+
35
+
```json
36
+
"launchBrowser": true,
37
+
"launchUrl": "swagger",
38
+
```
39
+
28
40
## Use Scalar for interactive API documentation
29
41
30
42
[Scalar](https://scalar.com/) is an open-source interactive document UI for OpenAPI. Scalar can integrate with the OpenAPI endpoint provided by ASP.NET Core. To configure Scalar, install the `Scalar.AspNetCore` package.
@@ -33,6 +45,16 @@ As a security best practice on limiting information disclosure, ***OpenAPI user
33
45
34
46
Launch the app and navigate to `https://localhost:<port>/scalar/v1` to view the Scalar UI.
35
47
48
+
To automatically launch the app at the Scalar UI URL using the `https` profile of `Properties/launchSettings.json`:
49
+
50
+
* Confirm that `launchBrowser` is enabled (`true`).
51
+
* Set the `launchUrl` to `scalar/v1`.
52
+
53
+
```json
54
+
"launchBrowser": true,
55
+
"launchUrl": "scalar/v1",
56
+
```
57
+
36
58
## Lint generated OpenAPI documents with Spectral
37
59
38
60
[Spectral](https://stoplight.io/open-source/spectral) is an open-source OpenAPI document linter. Spectral can be incorporated into an app build to verify the quality of generated OpenAPI documents. Install Spectral according to the [package installation directions](https://github.com/stoplightio/spectral#-installation).
Copy file name to clipboardExpand all lines: aspnetcore/performance/caching/hybrid.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ Notice that the inline interpolated string syntax (`$"..."` in the preceding exa
86
86
87
87
* Keys can be restricted to valid maximum lengths. For example, the default `HybridCache` implementation (via `AddHybridCache(...)`) restricts keys to 1024 characters by default. That number is configurable via `HybridCacheOptions.MaximumKeyLength`, with longer keys bypassing the cache mechanisms to prevent saturation.
88
88
* Keys must be valid Unicode sequences. If invalid Unicode sequences are passed, the behavior is undefined.
89
-
* When using an out-of-process secondary cache such as `IDistributedCache`, the specific backend implementation may impose additional restrictions. As a hypothetical example, a particular backend might use case-insensitive key logic. The default `HybridCache` (via `AddHybridCache(...)`) detects this scenario to prevent confusion attacks, however it may still result in conflicting keys becoming overwritten or evicted sooner than expected.
89
+
* When using an out-of-process secondary cache such as `IDistributedCache`, the backend implementation may impose additional restrictions. As a hypothetical example, a particular backend might use case-insensitive key logic. The default `HybridCache` (via `AddHybridCache(...)`) detects this scenario to prevent confusion attacks or alias attacks (using bitwise string equality). However, this scenario might still result in conflicting keys becoming overwritten or evicted sooner than expected.
90
90
91
91
### The alternative `GetOrCreateAsync` overload
92
92
@@ -117,7 +117,16 @@ Set tags when calling `GetOrCreateAsync`, as shown in the following example:
117
117
118
118
Remove all entries for a specified tag by calling <xref:Microsoft.Extensions.Caching.Hybrid.HybridCache.RemoveByTagAsync%2A> with the tag value. An overload lets you specify a collection of tag values.
119
119
120
-
When an entry is removed, it is removed from both the primary and secondary caches.
120
+
Neither `IMemoryCache` nor `IDistributedCache` has direct support for the concept of tags, so tag-based invalidation is a *logical* operation only. It does not actively remove values from either local or distributed cache. Instead, it ensures that when receiving data with such tags, the data will be treated as a cache-miss from both the local and remote cache. The values will expire from `IMemoryCache` and `IDistributedCache` in the usual way based on the configured lifetime.
121
+
122
+
## Removing all cache entries
123
+
124
+
The asterisk tag (`*`) is reserved as a wildcard and is disallowed against individual values. Calling `RemoveByTagAsync("*")` has the effect of invalidating *all*`HybridCache` data, even data that does not have any tags. As with individual tags, this is a *logical* operation, and individual values continue to exist until they expire naturally. Glob-style matches are not supported. For example, you can't use `RemoveByTagAsync("foo*")` to remove everything starting with `foo`.
125
+
126
+
### Additional tag considerations
127
+
128
+
* The system doesn't limit the number of tags you can use, but large sets of tags might negatively impact performance.
129
+
* Tags can't be empty, just whitespace, or the reserved value `*`.
Copy file name to clipboardExpand all lines: aspnetcore/test/integration-tests.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Integration tests ensure that an app's components function correctly at a level
16
16
17
17
:::moniker range=">= aspnetcore-10.0"
18
18
19
-
This article assumes a basic understanding of unit tests. If unfamiliar with test concepts, see the [Unit Testing in .NET Core and .NET Standard](/dotnet/core/testing/) article and its linked content.
19
+
This article assumes a basic understanding of unit tests. If unfamiliar with test concepts, see the [Testing in .NET](/dotnet/core/testing/) article and its linked content.
20
20
21
21
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/test/integration-tests/10.x/IntegrationTestsSample) ([how to download](xref:index#how-to-download-a-sample))
22
22
@@ -325,4 +325,4 @@ The SUT's database context is registered in `Program.cs`. The test app's `builde
Copy file name to clipboardExpand all lines: aspnetcore/test/troubleshoot.md
+4-82Lines changed: 4 additions & 82 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ author: tdykstra
4
4
description: Understand and troubleshoot warnings and errors with ASP.NET Core projects.
5
5
ms.author: tdykstra
6
6
ms.custom: mvc
7
-
ms.date: 07/10/2019
7
+
ms.date: 5/2/2025
8
8
uid: test/troubleshoot
9
9
---
10
10
# Troubleshoot and debug ASP.NET Core projects
@@ -77,87 +77,9 @@ If an app is capable of responding to requests, you can obtain the following dat
77
77
78
78
Place the following [middleware](xref:fundamentals/middleware/index#create-a-middleware-pipeline-with-iapplicationbuilder) code at the beginning of the `Startup.Configure` method's request processing pipeline. The environment is checked before the middleware is run to ensure that the code is only executed in the Development environment.
79
79
80
-
To obtain the environment, use either of the following approaches:
81
-
82
-
* Inject the `IHostingEnvironment` into the `Startup.Configure` method and check the environment with the local variable. The following sample code demonstrates this approach.
83
-
84
-
* Assign the environment to a property in the `Startup` class. Check the environment using the property (for example, `if (Environment.IsDevelopment())`).
Get the environment from the `Environment` property of `WebApplication`. For example, `if (app.Environment.IsDevelopment())` as in the following sample code.
0 commit comments