Re-evaluate enhanced nav to non-Blazor endpoints #50591
Labels
area-blazor
Includes: Blazor, Razor Components
enhancement
This issue represents an ask for new feature or an enhancement to an existing one
Milestone
Enhanced links (GET) and enhanced forms (POST) only occur if the target URL is internal to your origin, but it doesn't know or account for whether the target is a Blazor endpoint. It could turn out that you're doing enhanced nav to an MVC page, for example.
Right now this is simply allowed to happen and for most pages it works fine. You see the new content, you're at the new URL, everything continues.
However, this means you have some MVC-emitted markup running in a context it never intended to run in. The page already has scripts running, already has link click interceptors, and any amount of arbitrary Blazor code going in the background. The new content might not work properly because of the existing JS in the page, or because it relies on something like a "document ready" event that's never going to fire because the document was already ready long ago.
Suggestion
We should make Razor Component endpoints/results include an HTTP header,
blazor-enhanced-nav: allow
. Then we change the JS enhanced nav code so that if the response doesn't include this header:In the case of redirections, this is already covered and works well, whether or not the redirection is issued by Blazor code on the server. That's out of scope for this issue; here we're only concerned with getting back HTML from an internal but non-Blazor endpoint.
The text was updated successfully, but these errors were encountered: