Hey Everyone-
I have some code in a controller (HomeController.cs) that gets called from a $.get method in my view.
View Code
$(document).ready(function() {
$.get("/Home/Toolbar", function(result) {
$("body").prepend(result);
});
});
HomeController.cs
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Toolbar()
{
if (Request.IsAuthenticated && Roles.IsUserInRole("Agents"))
return PartialView("toolbar");
return new EmptyResult();
}
My issue here is after the EmptyViewResult is returned to the JS, the code doesn't "post back" to the controller anymore. If I remove the "if" conditional and consisently return the PartialView, everything works correctly.
I would like to only include the "toolbar" partial view in the DOM, when the user is in the "Agents" role.