0
I want to block partialview url through url using [ChildActionOnly]
.
Face problem, follow code:
HTML:
<li style="cursor:pointer"><a id="button_id">Criar</a></li>
JS:
$("#button_id").click(function () {
$("#conteudoModal").load("@Url.Action("MinhaAcao", "Controller")", function () {
$('#minhaModal').modal('show');
});
});
Controller:
[HttpGet]
[ChildActionOnly] // <----- Aqui
public ActionResult MinhaAcao()
{
var model = new Model();
return PartialView(model);
}
Without [ChildActionOnly]
modal opens normal and with partialview url.
With [ChildActionOnly]
, by clicking on "Create" button, I get error message:
Exception Details: System.Invalidoperationexception: The Action 'Minhaacao' is accessible only for a daughter request.
Some solution ?
What is the error message?
– Jéf Bueno
@LINQ Error 500 as far as I understand.
– Aline
@Aline 500 That code says absolutely nothing. It is only a number that identifies the type of the HTTP response, where semantically it means there was an error on the server side. ASP.NET applications usually return a 500 response when an exception occurs, if an exception occurs there is a message and a stacktrace.
– Jéf Bueno
@LINQ, relax. If I have any route problem or permission, will return error 500 and no other information. That’s what I understand is happening to him. If you know how to provide more detailed information when it is not on the console, please reply, because I also want to know. = T
– Aline
@Aline did not understand the "relax". About the error message: you are mistaken, of course this will not happen. Error 500 will always return a page with the information that originated the exception. If the call is made via Javascript it is possible to see the page in the tab network of browser.
– Jéf Bueno
@LINQ, it’s true. You’re right. The page appears and everything else. And the relaxation was just force of expression.
– Aline