Is is possible to specify a POST action when defining items in the Kendo MVC UI Menu?
For example, I would like to include a menu item for the user to logout, which is supported by the following controller action:
(AccountController)
(sample.cshtml)
I'm trying to replicate the out-of-box MVC sample project that looks similar to this:
(_LoginStatus.cshtml)
For example, I would like to include a menu item for the user to logout, which is supported by the following controller action:
(AccountController)
[HttpPost]
[ValidateAntiForgeryToken]
public
ActionResult LogOff()
{
_webSecurityService.Logout();
_webSecurityService.Logout();
return
RedirectToAction(
"Index"
,
"Home"
);
}
(sample.cshtml)
@(Html.Kendo().Menu()
.Name("menu")
.Items(items =>
{
items.Add().Text("Home").Action("Index", "Home");
//...
items.Add().Text(User.Identity.Name)
.Items(children =>
{
//...
// this results in a 404 error
children.Add().Text("Sign out").Action("LogOff", "Account");
});
})
)
I'm trying to replicate the out-of-box MVC sample project that looks similar to this:
(_LoginStatus.cshtml)
<
text
>
Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues: null, htmlAttributes: new { @class = "username", title = "Manage" })!
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
@Html.AntiForgeryToken()
<
a
href
=
"javascript:document.getElementById('logoutForm').submit()"
>Sign out</
a
>
}
</
text
>