0
I have a method in my controller called ListagemTarefasEmDesenvolvimento() that returns me a PartialView. However, when I call this method via ajax, the server gives me a status error 500.
Below is my controller:
[HttpPost]
        public IActionResult ListagemTarefasEmDesenvolvimento()
        {
            var idUser = Int32.Parse(User.FindFirst("IdUsuario")?.Value);
            var obj = _tarefaContext.getTarefaEmDesenvolvimentoByIdUsuario(idUser).Result;
            
            var retorno = PartialView("_Em", obj);
            return retorno;
        }
The method getTarefaEmDesenvolvimentoByIdUsuario(), returns only one object. (does not return list).
This is my Partialview
    @model RKMES.Models.Tarefa
    <h6>Em Desenvolvimento</h6>
    <div class="panel panel-body panel-shadow border-top-verde overlayEmDesenvolvimento" style="padding:16px;padding-bottom:0; background-color:#ffffff">
    
        <div data-id="@Model.Id" class="row panel-shadow containerTarefasAFazer" style="margin-bottom:18px;padding:12px">
            <div>
                <div class="col-md-6">
                    <span style="font-size:16px"><strong>@Model.Nome</strong></span><br />
                    <span><strong>Atividade: </strong>@Model.Atividade.Nome</span><br />
                    <span><strong>Tempo previsto: </strong>@Model.HorasPrevisto</span>
                </div>
                <div class="col-md-6">
                    <div class="row">
                        <a style="float:right" onclick="PausarTarefa(@Model.Id)" class="btn btn-pausar btn-icon btn-rounded">
                            <i class="icon-pause2"></i>
                        </a>
                    </div>
                    <div class="row">
                        <a style="float:right" onclick="FinalizaTarefa(@Model.Id)" class="btn btn-roxo btn-icon btn-rounded">
                            <i class="icon-checkmark3"></i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
Some curiosities:
If I do the method
getTarefaEmDesenvolvimentoByIdUsuario()return a list of objects, and I make an adjustment in the view, everything works normally.From what I’ve seen in one of the building methods of
PartialView(), he expects an object as a second parameter, so in theory, what I did should work normally but I get error500.
Can anyone tell me where I’m going wrong?
Debug and see which is the error 500... only this information is not enough.
– Leandro Angelo