ProjectResourceBuilderExtensions.DisableForwardedHeaders Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Configures the project to disable forwarded headers when being published.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ProjectResource> DisableForwardedHeaders (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ProjectResource> builder);
static member DisableForwardedHeaders : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ProjectResource> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ProjectResource>
<Extension()>
Public Function DisableForwardedHeaders (builder As IResourceBuilder(Of ProjectResource)) As IResourceBuilder(Of ProjectResource)
Parameters
- builder
- IResourceBuilder<ProjectResource>
The project resource builder.
Returns
A reference to the IResourceBuilder<T>.
Examples
Disable forwarded headers for a project.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddProject<Projects.InventoryService>("inventoryservice")
.DisableForwardedHeaders();
Remarks
By default .NET Aspire assumes that .NET applications which expose endpoints should be configured to use forwarded headers. This is because most typical cloud native deployment scenarios involve a reverse proxy which translates an external endpoint hostname to an internal address.
To enable forwarded headers the ASPNETCORE_FORWARDEDHEADERS_ENABLED
variable is injected into the project and set to true. If the DisableForwardedHeaders(IResourceBuilder<ProjectResource>) extension is used this environment variable will not be set.