Problem saving columnLayout

Posted by: pablo on 14 December 2022, 8:53 am EST

    • Post Options:
    • Link

    Posted 14 December 2022, 8:53 am EST - Updated 14 December 2022, 8:59 am EST

    I have a problem saving the order of my Grid in my DataBase. I save the order with JavaScript using the property “.columnLayout” and i send the String to the controller where I save it at the DataBase.

    My code is working in local code debugging but when I upload It to the server It gives an error 403

    JS

    function guardarOrdenColumnas() {
            
            var grid = wijmo.Control.getControl("#theFlexGrid");
                var orden = grid.columnLayout;
    
                window.location.href = "@Html.Raw(Url.Action("GuardarOrdenColumnas", "tareas", new { ordenCol = "replaceToken", programa = "TareasPendientes"}))".replace("replaceToken", orden);
            
        }

    Controller

     public ActionResult GuardarOrdenColumnas(String ordenCol, String programa)
            {
                var usuario = HttpContext.Session.GetString("usuario");
    
                FicOrdenCol objOrdencol = new() { 
                ordenColGrid = programa,
                ordeColOrden = ordenCol,
                ordenColUsuario = usuario,
                };
    
                try
                {
                    if (dbContext_ordenCol.LeerFicOrdenColExiste(programa, usuario))
                    {
                        dbContext_ordenCol.ActualizarFicOrdenCol(objOrdencol, usuario);
                        switch (programa)
                        {
                            case "Tareas": return RedirectToAction("Index");
                            case "TareasPendientes": return RedirectToAction("IndexTareasPendientes");
                            case "CierreTareasPendientes": return RedirectToAction("IndexCierreTareasPendientes");
                            case "TareasDesviaciones": return RedirectToAction("IndexTareasDesviaciones");
                            case "TareasMes": return RedirectToAction("IndexTareasMes");
                            case "TareasParteFondeo": return RedirectToAction("IndexTareasParteFondeo");
                        }
                    }
                    else
                    {
                        dbContext_ordenCol.CreateFicOrdenCol(objOrdencol, usuario);
                        switch (programa)
                        {
                            case "Tareas": return RedirectToAction("Index");
                            case "TareasPendientes": return RedirectToAction("IndexTareasPendientes");
                            case "CierreTareasPendientes": return RedirectToAction("IndexCierreTareasPendientes");
                            case "TareasDesviaciones": return RedirectToAction("IndexTareasDesviaciones");
                            case "TareasMes": return RedirectToAction("IndexTareasMes");
                            case "TareasParteFondeo": return RedirectToAction("IndexTareasParteFondeo");
                        }
                    }
    
                    return View();
                    
                }
                catch (Exception e) {
                    return RedirectToAction("Index");
                }
            }

    Could it be a server configuration?

  • Posted 15 December 2022, 1:26 pm EST

    Hi,

    Error 403 is related to Authentication. And I doubt here that the issue is with the DataBase authentication to interact.

    Could you please recheck by interacting with the DB from the local machine?

    Please also refer to the following articles:

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403

    https://www.hostinger.in/tutorials/what-is-403-forbidden-error-and-how-to-fix-it

    Hope it helps!

    Regards,

    Manish Gupta

  • Posted 14 April 2023, 7:36 am EST

    Hello, I just solve the problem.

    When you send data through JS to a MVC controller, the data(grid.columnLayout) is sent through the browser Url and that’s when the error is generated.

    I have solved it creating a hidden form and sending the information through it instead of through the url and works fine.

  • Posted 16 April 2023, 11:20 pm EST

    Hi Pablo,

    Thank you for sharing the solution here that might help others in future.

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels