Description
The change recently made to always render the current fully qualified request URL as the value for any form
element rendered in a Razor component, causes issues when the app is deployed behind any kind of reverse proxy/ingress controller, which is extremely common for any hosting PaaS, including Azure App Service for Linux/Containers, and Azure Container Apps.
In these environments, the value of HttpRequest.Scheme
, HttpRequest.Host
, etc. will not reflect the values the browser client sees unless the forwarded headers middleware is added and properly configured. Doing so is a fairly complex task and tied strongly to the specific destination the app is deployed to.
Instead of using the fully qualified URL, MVC and Razor Pages renders the action
attribute with just the root-relative (absolute) path, i.e. /shopping/cart instead of http://contoso.com/shopping/cart, so that the scheme and host from the client's point of view, do not need to be known (it does this using IUrlHelper
). Note that this must still take into consideration the current value of HttpRequest.PathBase
if set. This makes it far simpler to have the application work correctly without need to configured forwarded headers.
We should update Blazor's form rendering logic to match what MVC and Razor Pages does, except that Blazor should always render a value (MVC skips it if it's for the current controller/action/page).