Blazor server components in existing MVC project - data access

Posted by: zippier_milk.0m on 7 November 2022, 7:36 pm EST

    • Post Options:
    • Link

    Posted 7 November 2022, 7:36 pm EST

    I have a large MVC project (recruitment) and I want to integrate Blazor Calendar component into one of the views.

    Let’s skip all the config issues I had with this and lets go straight to data access. Calendar is interactive and while clicking on it, modals pop up where you can enter data, edit, save etc. This will save to the DB.

    I can’t use MVC service layer as MVC uses scoped DBContext and there will be concurrency issues if dbContext isn’t Transient. Tried it out of curiosity, issues were intermittent - the worst kind of issues.

    I don’t want to build a whole ecosystem around one component, with separate dbContext connection, own services for data access, neither I want to build an API just for this - is there really no other option?

    Another way of accessing data is to create my own HttpClient (actually toying with this now) and Post/Get data to my MVC controllers rather than API.

    What is a “conventional” way of doing this when integrating Blazor into existing MVC, rather than when building A Blazor app from scratch?

    ps. Is it just me or the integration side of Blazor is a bit neglected, is it just not meant to be integrated and should be used as an exclusive frontend?

  • Posted 9 November 2022, 8:10 pm EST

    Hi,

    The best way would be to implement the Form and Submit the form to the API or Controller GET/POST methods.

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels