Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!