I have a button on my screen that held call to a method in my controller (Ajax) that returns a partialView by default.
$("#btn-Visualizar-Rotina").click(function() {
var codUnimetPcp = '@Model.UnidadeMetalica.COD_UNIMET_PCP';
$("#modal-Rotina").load("Rotina/Index", { "codUnimetPCP": codUnimetPcp }, function (result) {
$("#modal-Rotina").modal({
backdrop: 'static',
keyboard: true
}, 'show');
});
});
However, in my control, I need to re-validate if the user does indeed have permission on the method in question, and if not, derive to a default security page. In the validation function, when the user does not have access, I have the following code snippet
filterContext.Result = new ViewResult
{
ViewName = "~/Views/AcessoNegado.cshtml",
ViewData = filterContext.Controller.ViewData,
TempData = filterContext.Controller.TempData,
};
However, when this happens, my AcessoNegado.cshtml
page is not loading. It is being rendered within the modal.
I tried to return a ViewBag indicating that authentication failed to display the modal, but it always comes with null
.
I would like your help in solving this problem in the best way possible.