Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda