-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have a Blazor web app with an index page at the route "/".
When accessed through myhost/myapp everything works fine. However, I published the url in a Facebook post and when users tap that link FB appends a query parameter called fbclid - making the Blazor app fail.
The error message I get in the web server logs is "The URI 'http://myhost/myapp?fbclid=[...]' is not contained by the base URI 'http://myhost/myapp/'."
My Blazor page was like this:
@page "/"
<PageTitle>Index</PageTitle>
<h1>Welcome!</h1>
To handle the issue, I tried adding a query argument like this:
@page "/"
<PageTitle>Index</PageTitle>
<h1>Welcome!</h1>
@code {
[Parameter]
[SupplyParameterFromQuery(Name = "fbclid")]
public string FacebookClientId { get; set; }
}
... but the error remains.
I tried various URL's to access the page:
- http://myhost/myapp
displays the page as expected - http://myhost/myapp?fbclid=123
produces the error - http://myhost/myapp/?fbclid=123
displays the page as expected - notice the superfluous '/' character before the '?'
Hosting environment:
- IIS 7.5 (Windows 7)
- .NET Core Hosting Bundle
- Used VS File deploy to copy files to IIS
- Used IIS Manager to Convert [Directory] to application
Can not reproduce the isue on dev environemnt with VS and IIS express, where the default utl is localhost:7801, as the browser auto-inserts a slash before the question mark.
Expected Behavior
- http://myhost/myapp?fbclid=123
Should display the page without an error.
Steps To Reproduce
https://github.com/balintn22/BlazorApp1
- This is a result of creating a new project using the Visual Studio Blazor Web Server App template.
- Deploy to IIS
- Browse to the main page
- Append "?anyarg=anyvalue" to the url and reload
Exceptions (if any)
Category: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
EventId: 1
SpanId: be0b764e7346a06b
TraceId: 8686d0b717b40edc25ffc5ac2426f609
ParentId: 0000000000000000
RequestId: 800018a2-0000-ee00-b63f-84710c7967bb
RequestPath: /regattasearch
ActionId: 1a3bb4fc-e879-410a-ae02-d37122926a4b
ActionName: /_Host
An unhandled exception has occurred while executing the request.
Exception:
System.ArgumentException: The URI 'http://myhost/myapp?fbclid=123' is not contained by the base URI 'http://myhost/myapp/'.
at Microsoft.AspNetCore.Components.NavigationManager.Validate(Uri baseUri, String uri)
at Microsoft.AspNetCore.Components.NavigationManager.Initialize(String baseUri, String uri)
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.Initialize(String baseUri, String uri)
at Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer.g__InitializeCore|5_0(HttpContext httpContext)
at Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer.PrerenderComponentAsync(ParameterView parameters, HttpContext httpContext, Type componentType)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.PrerenderedServerComponentAsync(HttpContext context, ServerComponentInvocationSequence invocationId, Type type, ParameterView parametersCollection)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.RenderComponentAsync(ViewContext viewContext, Type componentType, RenderMode renderMode, Object parameters)
at Microsoft.AspNetCore.Mvc.TagHelpers.ComponentTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count)
at RegattaSearch.WebUI.BlazorServer.Pages.Pages__Host.ExecuteAsync() in C:_Src\Balint\RegattaSearch\RegattaSearch\RegattaSearch.WebUI.BlazorServer\Pages_Host.cshtml:line 8
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable
1 statusCode)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
.NET Version
dotnet6
Anything else?
In the dev environment
VS 2022, 17.9.5
Windows 10 Pro
the issue does not occur: on executing the web app, the browser appears tih the URL and the custom port. When I enter a query string, the browser inserts a '/' character in front of the '?'.