-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
[Blazor SS Question] Advantage of Blazor SS over ASP razor page? #9938
Comments
Short answer: use Blazor Server Side if you want to create interactive application and write your code in C#. Blazor template contains Another example. Let's assume you have two combo boxes. First contains a list of countries. Second should contain cities in selected country. The same suggestion as above: try to implement this in Razor pages or MVC without JavaScript or full page refresh. Try to create any complex LOB (Line of Business) application where you have to implement interactive invoice entry form. Application have to recalculate everything after each change (amount, price, discount, etc.). Tax regulations are complex (at least in Europe) and you need more than 1000 lines of code to handle all edge cases. In Razor pages/MVC application if you want to have interactive application you have to implement business logic in JavaScript and duplicate the same rules in C# to validate (recalculate) invoice on the server. This is very complex task. In Blazor you can implement your business logic in C# and it is enough. Take into account one more fact. In JavaScript there is no |
@Andrzej-W ; |
"My product has to be live before the end of the year." That's key. Honestly I'd go with Razor Pages. Blazor server side has to keep those signalr connections open, so if your app is going to have a lot of visitors that could take a toll on your servers. |
Let's assume you have to implement some complex algorithm which is necessary to make your page interactive. In Razor pages you have to write it in JavaScript. In Blazor you can write it in C#, and because it works on the server you can use any .NET library which is compatible with .NET Standard. If you implement your code in JavaScript everybody can see it, debug it, clone it, etc. Code on the server is safe - nobody have access to it. You also have to take into account some limitations of Blazor Server Side. All events are asynchronous. That is often the big problem - read #5545. To implement some functions you will need JavaScript no matter what. If you want to have good SEO and integration with social media you will have some problems in Blazor - read #9128.
If your project does not require to much interactivity and you are comfortable with JavaScript you should probably create it in Razor pages or MVC. |
@3x0dv5 & @Andrzej-W ; Thank you for your feedback. Digging deeper over the weekend in Asp Razor pages, one thing became very clear to me. Razor Pages are very well thought out and a "complete" platform, in some ways even better and cleaner than MVC. |
I've never done it, but can't see why not. In practically terms the browser doesnt know anything about the cshtml, the browser will only be concerned with the paths that you put in the In a PWA using client side blazor you will have a list of files to cache like:
But in your Razor pages you'll have urls that you might specify on the
so in your filesToCache you will want to add Razor pages might come short for a PWA when dealing with offline and submitting the data to the server once back online, for read only pages might work fine but dealing with scenarios to submit data to the server, let's say a messaging system, you may need to write some javascript to deal with it because you will want to keep the data in local cache and automatically submit it to the server once the app is back online. Don't know if makes sense... in short a PWA has plenty of client side logic. |
@3x0dv5 ; |
in that case shouldn't be a problem. Add the manifest.json, icons, and cache a few files to at least show that the app is offline and you can even test it on chrome on your lap/desktop. When you provide the manifest.json chrome will show a "Install {app name}..." on the menu and then you can see the app icon on your desktop (at least on Windows 10) |
@3x0dv5 |
You don't have to limit yourself. You can start with razor pages or mvc and when core 3.0 comes out, you can start gradually and at your own pace integrate components in your existing razor pages or mvc views. |
What are the main advantages in using Blazor Server Side over using ASP.Net Core Razor pages?
Structurally and functionally when I look at both, they both seem to be the same (some changes to routing and where code gets written) but as far using EF, building pages, serving them to user seem the same. In fact Razor pages offer powerful Taghelpers that Blazor doesn't and razor pages are mature and solid.
So why should I use Blazor for future project than good old MVC or Razor pages. This question is only for Blazor Server Side and not client side.
Thank you in advance!
..Ben
The text was updated successfully, but these errors were encountered: