Search code examples
razorblazor

can i access blazor(.razor) in razor page(cshtml)?


my project is made blazor server

I got a text editor that works with blazor(.razor) . But all my default pages are razor pages (.cshtml).

How to access with blazor(.razor) parameter in cshtml?

I initially used asp-for . And I tried to use url/{value} method through navlink. When I used navlink in cshtml, the button did not appear.

i find that no!

Is what I'm trying to do possible?

<a asp-page="./ViewBorad" asp-route-boradid="@Model.board.board_id" > AddText</a>

<li class="nav-item px-3">
    <NavLink class="nav-link" href="/MyPage/ViewBorad/@Model.board.board_id">
        <span class="oi oi-plus" aria-hidden="false"></span> ViewBorad
    </NavLink>
</li>


Solution

  • You can navigate to a Razor page from Blazor by using the NavigationManager.NavigateTo method which takes two parameters. The first parameter is the url to navigate to, including a parameter the called method gets, the second named forceLoad, which takes a boolean value... The default value is false, but you should pass a true value.

    Search Google for the string enet stackoveflow Blazor OpenIDConnect, inspect the results where I show how to call a Razor page from a Razor component (Blazor), how to pass a parameter to and back.

    Incidentally, you can also use the NavLink or the Html anchor element (a element) for this.