MVC view is not rendered in Asp.net

0

I have a view that is not rendered, but on the contrary, it shows the data of a viewmodel that I am passing through the controller to fill a dropdownList.

This is my controller

        public ActionResult Inicio()
    {

        int KamId = 1;
        TW.Business.Kam.DatosKam ck = new DatosKam();
        VM_ComboClientesKam VM_cmbCliKam = ck.GetComboClientesKam(KamId);
        if (VM_cmbCliKam != null)
        {
            return Json(new { data = VM_cmbCliKam }, JsonRequestBehavior.AllowGet);
        }
        return View();
    }

here:

@model TW.Model.Kam.ViewModels.VM_ComboClientesKam


<div id="InfoProceso" class="jumbotron">
        <h1>Cierre de Mes</h1>
        <p class="lead">Proceso de cierre de mes, permite ingresar informacion de asistencia, bonos y descuentos de los trabajadores TeamWork.</p>

        <p><a href="https://asp.net" class="btn btn-primary btn-lg">Ver mas &raquo;</a></p>
</div>


<div id="SeleccionaCliente">
    <p class="lead">Seleccione un cliente para definir la plantilla a utilizar</p>

    <p>
        <div>
            @Html.DropDownListFor(m => m.SelectedCliente, new SelectList(Model.lstClientesKam, "ClienteId", "ClienteNombre"))
        </div>
    </p>
</div>

The viewmodel through which I pass the data is:

    public class VM_ComboClientesKam
{
    public IEnumerable<VM_ClientesViewModel> lstClientesKam { get; set; }
    public int SelectedCliente { get; set; }
}

public class VM_ClientesViewModel
{
    public int ClienteId { get; set; }
    public string ClienteNombre { get; set; }
}

Does this happen to someone?

What returns the page, is a json with the data of the combobox.

{"data":{"lstClientesKam":[{"ClienteId":1,"ClienteNombre":"Artel S.A.I.C."},{"ClienteId":2,"ClienteNombre":"BCI CORREDORES DE SEGUROS S.A."},{"ClienteId":3,"ClienteNombre":"BCI SEGUROS VIDA S.A."}],"SelectedCliente":0}}
    
asked by Luis Gabriel Fabres 30.11.2018 в 19:52
source

1 answer

0

I realized that I was doing something wrong.

I was responding with a json:

return Json(new { data = VM_cmbCliKam }, JsonRequestBehavior.AllowGet);

And not with a view, as expected.

    
answered by 30.11.2018 в 20:40