RadzenPanelMenuItem with POST functionality

Hi Radzen Team,
I'm experimenting with RadzenPanelMenuItem the side menu for Login/Logout operations.

<RadzenPanelMenu>
   ...
    <AuthorizeView>
        <Authorized>
            ...
            <RadzenPanelMenuItem Text="Logout" Icon="logout" Path="Account/Logout"></RadzenPanelMenuItem>
        </Authorized>
        <NotAuthorized>
            ...
            <RadzenPanelMenuItem Text="Login" Icon="login" Path="Account/Login"></RadzenPanelMenuItem>
        </NotAuthorized>
    </AuthorizeView>
   ...
</RadzenPanelMenu>

For Login, I got the solution in another post, but this doesn't work for Logout because it's necessary to include an <AntiForgeryToken />.
This means that I must use a RadzenTemplateForm instead of a RadzenPanelMenuItem.

<RadzenPanelMenu>
   ...
    <AuthorizeView>
        <Authorized>
            ...
            <RadzenPanelMenuItem Text="Logout" Icon="logout" Path="Account/Logout"></RadzenPanelMenuItem>
        </Authorized>
        <NotAuthorized>
            ...
            <RadzenTemplateForm  Action="Account/Logout" Method="post" TItem="string" >
                <ChildContent Context="AChildContext">
                    <RadzenFieldset>
                        <AntiforgeryToken />
                        <RadzenTextBox @bind-Value="@returnUrl" Name="returnUrl" hidden="true"/>
                            <RadzenButton ButtonType="ButtonType.Submit" Icon="logout" Text="Logout" Variant="Variant.Text"></RadzenButton>
                    </RadzenFieldset>
                </ChildContent>
            </RadzenTemplateForm>
        </NotAuthorized>
    </AuthorizeView>
   ...
</RadzenPanelMenu>

This is ok, but the resulting style for the Logout button is completely different than the nice RadzenPanelMenuItem style.

So, now, my question: could it be possible to have a RadzenPanelMenuItem that works with a Method="post" and could include elements like <AntiForgeryToken /> and attributes like returnUrl?
That could be really gooood! (:sunglasses:)

I'm afraid that this is not possible. The PanelMenu is a simple navigation component and cannot make POST requests.

Hi mpolazzo - did you do a workaround here? I have the same exact issue :slight_smile:

Hi, unfortunately not.
I included in the menu a RadzenButton with the style of all the other buttons in my app and handle the POST in the button callback function.
It’s not bad, at the end of the day your logout button will result very visible.

I just dumped the form to be posted somewhere hidden and used Click on RadzenPanelMenuItem to call a javascript function, that submitted the form, using JsRuntime.InvokeVoidAsync.

Not very elegant, but it seems to work :slight_smile:

Great. Thanks for sharing.