[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
5.62k
stars
2.14k
forks
source link
Feature Request: Enable Execution of Server-side Razor Logic to run on Client #8784
I'm not sure if what I'm asking is even possible, but I figure with the advancements we are getting with WebAssembly and consequently Blazor, that this would be the correct place to pose this request.
I love the Razor Pages programming model. I think it works great and it is delightfully simple to use. The only problem I have (and this is no fault of Razor Pages, its just the state of web development) is that in order to do even the simplest bit of manipulation on the client-side, I have to use JavaScript, more specifically I have to transition my domain model written in C# an equivalent representation in JavaScript.
What I would love to see is the ability to have logic that would typically only run on the initial page load, to also run on the client.
For example, I have a block of Razor that looks like this:
When the user updates the checkbox, I'd like to be able to have it display (or not display) the "woot" element without having to use JavaScript and without having to do a page refresh, and I would rather not have to use full-blown Blazor or a SPA approach because again, this is relatively simple logic. Essentially I'd like to extend the logic that is already in the Razor Page to work on the client as well as the server.
I know that we are getting Razor Components in ASP.NET Core 3, which is promising, but my understanding with Razor Components is that we are still building an SPA style app, but we are just moving the SPA from the client to the server.
This approach would allow for existing Razor Pages apps to be able to leverage all the advancements that we are getting from WebAssembly and Blazor, but in a way that we really dont have to change how we write our apps, other than we no longer have to mix and match what runs on the initial render vs what runs throughout the lifecycle of the page.
The only reason I bring this up is because I still would love to use Razor Pages, but I would also like to add some nice client-side interactivity without having to switch contexts to JavaScript and without having to do a network hop (via a SignalR connection or otherwise). This probably sounds petty considering the example I proposed above could be accomplished pretty simply with even vanilla JavaScript, but the applications here could be taken a lot further than this trivial example.
I'm not sure if what I'm asking is even possible, but I figure with the advancements we are getting with WebAssembly and consequently Blazor, that this would be the correct place to pose this request.
I love the Razor Pages programming model. I think it works great and it is delightfully simple to use. The only problem I have (and this is no fault of Razor Pages, its just the state of web development) is that in order to do even the simplest bit of manipulation on the client-side, I have to use JavaScript, more specifically I have to transition my domain model written in C# an equivalent representation in JavaScript.
What I would love to see is the ability to have logic that would typically only run on the initial page load, to also run on the client.
For example, I have a block of Razor that looks like this:
When the user updates the checkbox, I'd like to be able to have it display (or not display) the "woot" element without having to use JavaScript and without having to do a page refresh, and I would rather not have to use full-blown Blazor or a SPA approach because again, this is relatively simple logic. Essentially I'd like to extend the logic that is already in the Razor Page to work on the client as well as the server.
I know that we are getting Razor Components in ASP.NET Core 3, which is promising, but my understanding with Razor Components is that we are still building an SPA style app, but we are just moving the SPA from the client to the server.
This approach would allow for existing Razor Pages apps to be able to leverage all the advancements that we are getting from WebAssembly and Blazor, but in a way that we really dont have to change how we write our apps, other than we no longer have to mix and match what runs on the initial render vs what runs throughout the lifecycle of the page.
The only reason I bring this up is because I still would love to use Razor Pages, but I would also like to add some nice client-side interactivity without having to switch contexts to JavaScript and without having to do a network hop (via a SignalR connection or otherwise). This probably sounds petty considering the example I proposed above could be accomplished pretty simply with even vanilla JavaScript, but the applications here could be taken a lot further than this trivial example.
Thanks for reading and keep up the good work!