Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
kjeske opened this issue May 10, 2023 · 2 comments
Closed
1 task done

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

kjeske opened this issue May 10, 2023 · 2 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@kjeske
Copy link

kjeske commented May 10, 2023

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

@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label May 10, 2023
@javiercn
Copy link
Member

@kjeske thanks for contacting us.

We are working on server side rendered applications based on components, which will have a relatively similar mode as this one, which is tracked at #46399.

That said, I want to be very clear that we don't plan to offer something like htmx, but you are still free to use that in your app if you want to.

@javiercn javiercn added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label May 10, 2023
@ghost ghost added the Status: Resolved label May 10, 2023
@kjeske
Copy link
Author

kjeske commented May 10, 2023

Progressive enhancement will be an awesome change. Can't wait to test it out once it's there. Thank you!

@kjeske kjeske closed this as completed May 10, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants