Error 500 (Internal Server Error) Get

Asked

Viewed 44 times

0

ERROR

GET http://localhost:54446/Tasks/Listrintegrants? team=1 500 (Internal Server Error)

HTML

@using (Html.BeginForm()) 
{

  <div class="form-horizontal">
    <h4>TarefaViewModel</h4>
    <hr />
    <div class="form-group">
        @Html.LabelFor(model => model.EquipeId, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownListFor(model => model.EquipeId, Model.Equipes, "--Selecione", new { @class = "form-control" })
        </div>
    </div>
    <div class="form-group">
        @Html.LabelFor(model => model.IntegranteId, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <select id="IntegranteId" class="form-control"></select>
        </div>
    </div>
    <div class="form-group">
        @Html.LabelFor(model => model.Descricao, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Descricao, new { htmlAttributes = new { @class = "form-control" } })
        </div>
    </div>
    <div class="form-group">
        @Html.LabelFor(model => model.Conclusao, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Conclusao, new { htmlAttributes = new { @class = "form-control" } })
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
</div>

Controller

        [HttpGet]
        public ActionResult ListarIntegrantes(int id)
        {
            GerenciadorContexto ctx = new GerenciadorContexto();
            var lista = new List<EquipedeIntegrante>();

            try
            {
                lista = ctx.EquipedeIntegrantes.Where(m => m.EquipeId == id).ToList();
            }
            catch (Exception ex)
            {

                throw;
            }

            return Json(new { Resultado = lista }, JsonRequestBehavior.AllowGet);
        }

SCRIPT

$(document).ready(function () {

    $("#EquipeId").change(function () {

        var value = $("#EquipeId option:selected").val();

        if (value !== 0 || value !== undefined)
        {
            ListarIntegrantes(value);
        }

    })

})

function ListarIntegrantes(value)
{

    var url = "/Tarefas/ListarIntegrantes";
    var data = { equipe: value };
    $("#EquipeId").empty();
    $.ajax({

        url: url,
        type: "GET",
        datatype: "json",
        data: data
    }).done(function (data) {

        if (data.Resultado.length > 0) {
            var dadosGrid = data.Resultado;
            var opt = "";
            $.each(dadosGrid, function (indice, item) {
                opt += '<option value="' + item["Id"] + '">' + item["Nome"] + '</option>';
            })
            $("#EquipeId").append('<option value="">--Selecione</option>' + opt);
        }
        })
    }
  • He’s probably getting into it Catch, nay?

  • You should detail more about the error. When? No load da view? Na controller? What part of the code?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.