locked
Trying to get my head around different ways of using Razor Pages RRS feed

  • Question

  • User853731431 posted

    Correct me if Im wrong, but since Razor Pages and their handler methods generally return a viewmodel, the whole page needs to refresh to handle this.  So there are different ways of setting up a razor page, much like there are with a MVC application.  Some of them are

    - Handler methods.  Each method returns a model
    - Named handler methods.  Each handler method is referenced via seperate form tag from within the razor page
    - Partial pages
    - Partial pages with Ajax, which lets you update sections of a page without refreshing the whole page
    - Using a separate web api combined with jQuery to fetch data and update sections of a page. 

    That about sum it up?  Please correct where Im wrong.

    Wednesday, May 6, 2020 11:11 PM

All replies

  • User475983607 posted

    Razor Pages are a server side UI framework.  If your intention is client side UI rendering then Razor Pages is not a good option.  It can work but not the best tool for the job.

    Wednesday, May 6, 2020 11:16 PM
  • User853731431 posted

    As of now, the approach/architecture Im using involves using
    - Telerik asp.net core library for UI components
    - Razor pages which references model classes defined in a separate library of the solution
    - Web api that recieves/returns models of the same classes in the library that the razor pages references
    - After the initial page loads, any additional data fetching/updates are done via jQuery and AJAX calls to the web api

    It seems to work pretty well so far. The benefits I see are:
    - No dependency on npm 
    - Simple project structure
    - Model classes defined once and reused in both the page as well as the api

    Wednesday, May 6, 2020 11:41 PM
  • User711641945 posted

    Hi BitShift,

    Handler methods.  Each method returns a model

    Razor pages work as one so you do not have to return the Model. You just bind it and you have access inside the page.

    And the other content you said seems to be quite well.

    Best Regards,

    Rena

    Thursday, May 7, 2020 9:41 AM