Trying to have an AJAX action reference that, when clicked, should do an HttpGet for the action method, which returns a PartialViewResult and drags the HTML into the div.
Here is my view:
<div id="admin-options" class="admin"></div> @Ajax.ActionLink("Show Admin Options", "ShowOptions", "Post", new { area = "Admin" }, new AjaxOptions { UpdateTargetId = "admin-options", HttpMethod = "GET" })
Here's the action method:
public class PostController : Controller { [HttpGet] [Authorize(Roles="Admin")] public PartialViewResult ShowOptions() { return PartialView(); } }
Here's the HTML it generates:
<a data-ajax="true" data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#admin-options" href="/Admin/Post/ShowOptions">Show Admin Options</a>
It looks good to me.
But instead of making an AJAX call, it does a normal HTTP GET via the browser URL and redirects to / Admin / Post / ShowOptions .
Obviously something is missing, but what?
ajax asp.net-mvc asp.net-mvc-3 razor actionlink
RPM1984 Apr 20 2018-11-11T00: 00Z
source share