locked
Blazor multiple components and free coding RRS feed

  • Question

  • User623986848 posted

    Hello everyone,

    I need a site that is very sensitive to SEO, so I prefer a site that has several pages that are pided into different matters, compiled on the server, and provided to explore as HTML.

    There are some components that I need to use them with Ajax.

    I am not interested in working with WebSocekts and therefore neither SignalR, nor with Blazor Server.

    I need components in different places on the pages (sometimes more than one place on each page), where people fill in several fields and send them to the server.

    Blazor WASM is written in the head of components, and probably rightly so, but I sometimes want to write simple commands I would do with Jquery for example like server calls, and I no longer want to use JS, is it possible to write free C # code that does not depend on areas (where components are located)?

    I do not want to write the Ajax in JS anymore, is it possible to perform the task with Blazor in C #.

    Or maybe there is a way (even through areas) to get what I need?

    That is:

    1. Each page has an app that uploads a different component (the pages are different razor pages (not SPA) who share a layout, the pages are rendered from the server.

    2. Is there a possibility to place different areas on the page, how do I tell each component where to enter?

    3. Is it planned to enable writing free C # code in the future with Blazor (without placing it in a component), just using http.Get() type of behaviour - without a component - like in Jquery or JS?

    Thank you!

    Monday, July 27, 2020 5:47 PM

All replies

  • User-474980206 posted

    you misunderstand blazor. WASM is a browser feature that implements a tiny VM/sandbox you can run binary (not javascript) code in. This sandbox does not have network, file, timer, or access to the dom. It must interop to javascript for these features. 

    for Blazor WASM, Microsoft wrote a small .net runtime that runs in WASM (currently a subset of .netstandard 2.1). Then a hosting javascript framework, that loads the runtime and .net modules needed for the Blazor app. when the Blazor app needs to update the dom (or make a network call) it does a javascript interop to the javascript framework. The javascript framework also captures events and calls the blazor code to process.

    This is a long way from html calling a local C# routine.

    so to do ajax, it would be:

    • browser event calls javascript
    • javascript calls blazor with event info
    • blazor build ajax request and calls javascript 
    • javascript makes ajax call
    • javascript calls blazor with ajax results
    • blazor process ajax results
    • blazor call javascript to display results

    Monday, July 27, 2020 9:33 PM