Skip to content

Razor pages with smooth DOM updates using ajax calls and websockets #48159

Closed
@kjeske

Description

@kjeske

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I was using quite a bit with Razor pages and I think it works great for server-side web applications. However, it's still reloading the full page after navigation / form requests. I know we have things like Razor Components (Blazor Server and Blazor wasm), but the problem I have with them is that both of them introduce quite radical concepts/changes. At some point it will for sure work out and be great, but they both struggle with some early issues that still need to be solved.

That's why I thought it would be great to have also something more conventional, like Razor Pages, but with additional great features to make them feel more like SPA: fast and clever content reloading, no full page reloads when not needed/ websockets support out of the box.

I've been playing recently with HTMX and it's really a thing. It introduces some simple concepts of calling ajax requests and reloading only the content you want in a seamless way. It works great, but it misses 2 things:

  • decent support from .NET side,
  • all the changes are being done using only using HTTP requests. Websocket support is possible but painful if you want to use it for Razor rendering.

What if we could have Razor Pages that work as today (full page reload), but with some additional optional features to:

  • call the page handlers in the ajax manner
  • render whole view and apply the dom changes in a clever way (either swapping the whole body content or an option to apply only the DOM differences, like morphdom does)
  • possibly having an option to say what parts of the page should be synced, using html ids or some other clever ways
  • make it possible to call page handlers using web sockets with no pain, so the communication can be even faster. If web socket connection fails, fallback to http ajax calls

It's similar concept to Turbo.
I can still create a third party library for this concept, but I believe .NET community would really benefit from having such way of working with razor pages that render pages on the server, which is bult-in to the .NET ecosystem.

Describe the solution you'd like

Razor Pages that work as today (full page reload), but with some additional optional features to:

  • call the page handlers in the ajax manner
  • render whole view and apply the dom changes in a clever way (either swapping the whole body content or an option to apply only the DOM differences, like morphdom does)
  • possibly having an option to say what parts of the page should be synced, using html ids or some other clever ways
  • make it possible to call page handlers using web sockets with no pain, so the communication can be even faster. If web socket connection fails, fallback to http ajax calls

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: DuplicateResolved as a duplicate of another issueStatus: Resolvedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions