ArgumentException: The path in 'value' must start with '/'. (Parameter 'value')
[Enter feedback here] Hello,
As I'm using some options in static files I read the docs and used:
app.MapWhen(ctx => !ctx.Request.Path
.StartsWithSegments("_framework/blazor.server.js"),
subApp => subApp.UseStaticFiles(new StaticFileOptions() { ... }));
To be precise I used this:
app.MapWhen(ctx => !ctx.Request.Path.StartsWithSegments("_framework/blazor.server.js"), sub => sub.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx2 =>
{
ctx2.Context.Response.Headers.Append("Cache-Control", $"must-revalidate, max-age={CacheMaxAge}");
ctx2.Context.Response.Headers.Append("Expires", DateTime.UtcNow.AddDays(1).ToString("R", CultureInfo.InvariantCulture));
}
}));
With configuration from docs I'm getting an error: ArgumentException: The path in 'value' must start with '/'. (Parameter 'value')
adding / to StartsWithSegments("/_framework/blazor.server.js") solved the issue
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: b0af7f84-f8dd-92d9-dacd-2aab76d3a039
- Version Independent ID: 25458428-030f-6acb-457e-1b4dfa722043
- Content: ASP.NET Core Blazor static files
- Content Source: aspnetcore/blazor/fundamentals/static-files.md
- Product: aspnet-core
- Technology: aspnetcore-fundamentals
- GitHub Login: @guardrex
- Microsoft Alias: riande