Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
ASP.net MVC timeout issue with Button Control

I have a simple asp.net mvc application with some dev controls. Main screen has a button that takes date from screen and does back end processing. VIEW:

@Html.DevExpress().Button(settings =>
                {
                    settings.Name = "LoadData";
                    settings.Text = "Load Data";
                    settings.ToolTip = "Imports data from Holding API"; 
                    settings.ClientSideEvents.Click = "OnClick";
                    settings.UseSubmitBehavior = false;
                }).GetHtml()

 function OnClick(s, e) {
        positionDate = ReportingPositionDate.GetDate().toDateString();
       $.ajax({
            type: "POST",
            //url: "/ImportData/DataFileUpload",
            url: "@Url.Action("DataFileUpload", "ImportData")",
            data: JSON.stringify({ positionDate: positionDate }),
            dataType: "text",
            contentType: "application/json; charset=utf-8",
            beforeSend: function () { lpImport.Show(); },
            success: function (msg)
            {
                ImportDataGridView.PerformCallback();
                ImportSuccessMessage.SetVisible(true);
                ImportSuccessMessage.SetText(msg);
                lpImport.Hide();
            },
            Error: function (xhr) {
                alert(xhr)
                ImportDataGridView.PerformCallback();
            }
        });
    }
}

Controller:

[HttpPost]
public ActionResult DataFileUpload(string positionDate)
{
    // Reset validation error collection
    ImportDataValidationErrors = new List<ImportFileRecord>();
    string[] errs;
    try
    {
        ReturnVal ="Some Long Running Process"
        return Content(ReturnVal);
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

Process takes about 50 minutes (or more) to run (expected). Controller method DataFileUpload does all actions correctly when it comes to returning to View, it just hangs up. My guess is that my screen has timed out and not accepting any response from the controller. When I run same process with smaller dataset, view get value back from Controller. Any idea what could be going wrong here? Any issue with my button settings ? Appreciate all help.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Jquery Ajax default timeout value is 0. This means no timeout in ajax. If the browser has some timeout it's entirely possible you'll hit that.

Only when a timeout option is specified does jQuery even call setTimeout().

Also there is another challenge. There is browser timeout for ajax (XMLHttpRequest), its different for each browser especially for IE. I guess its 30 min or so. Technically you can set timeout : 10000000 its between 2.30~3 hours.

I faced this problem before. You can solve with progress bar. With progress bar you can keep refreshed your view.

For simple ajax request that you can use.

function uploadFile(){
    myApp.showProgressDialog; //show dialog
    var file=document.getElementById('fileName').files[0];
    var formData = new FormData();
    formData.append("file_name", file);
    ajax = new XMLHttpRequest();
    ajax.upload.addEventListener("progress", ProgressBarHandler, false);
    ajax.addEventListener("load", OnCompleteHandler, false);
    ajax.open("POST", "/to/action");
    ajax.send(formData);
}

function ProgressBarHandler(event){
    var percent = (event.loaded / event.total) * 100;
    $('.bar').width(percent); // its coming from css
}

function OnCompleteHandler(){
    myApp.hidePleaseWait(); //hide dialog
    $('.bar').width(100);
}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda