Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:31:07+00:00 2026-05-22T21:31:07+00:00

I have come across this thread already, but I might need something else for

  • 0

I have come across this thread already, but I might need something else for my situation.

I have an action that returns a ViewResult, which is called by the client’s $.post()

JavaScript:

var link = 'GetFoo?fooBar=' + fooBar;

var jqxhr = $.post(link, function (response) {
    $('#myDiv').replaceWith(response);
});

Controller:

public ViewResult GetFoo(String fooBar)
{
    if (Request.IsAjaxRequest())
    {
        // perform a ridiculously long task (~12 minutes)           
        // algorithm: 1) download files from the Azure blob storage
        // 2) update each file
        // 3) reupload to blob storage
        // 4) return a list of URIs to be displayed to the UI
        return View("MyFooView", data);
    }
    throw new InvalidOperationException();
}

As the comment implies, there is long task running inside the Controller. (This is a document generation module that uploads PDFs to the Azure blob storage and returns a link to it to the View.)

This is working fine in my dev machine but when it goes live in a (secure) Azure production environment, it times out. I have put in lots of logging entries everywhere and as it turns out, it is able to upload the documents and return to the controller (i.e. it reaches the controller return statement above). However, when it is time to return the model data to the View, the client script doesn’t called back (i.e. the div content doesn’t get replaced with the results).

Is there a way to somehow prolong the timeout of the call? It is difficult to reproduce in my (unsecure) local environment so a definitive fix will help.

If I use the attribute [AsyncTimeout(3600)] on my GetFoo() method, then this action never gets called from the UI.

Any suggestions will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:31:07+00:00Added an answer on May 22, 2026 at 9:31 pm

    The problem is that the Azure load balancer has it’s own timeout which is set to one minute. Any request that takes longer than a minute gets terminated. There is no way to change this.

    The way around this in the Azure environment is to have one ajax call start the process and return some sort of process ID then have the client poll another ajax call to passing in this process ID to see if it’s complete. It might looks something like this uncompiled and untested code. In javascript:

    var link = 'BeginFooProcessing?fooBar=' + fooBar;
    
    var jqxhr = $.post(link, function (response) {
        var finishedlink = 'CheckFooFinished?fooId=' + response;
    
        // Check to see if we're finished in 1 second
        setTimeout("CheckIfFinishedYet('" + finishedlink + "')", 1000);
    });
    
    function CheckIfFinishedYet(finishedlink) {
        var response = $.post(finishedlink, function (response) {
            if (response == null) {
                // if we didn't get a result, then check in another second
                setTimeout("CheckIfFinishedYet('" + finishedlink + "')", 1000);
            }
            else {
                // Yay, we've got a result so we'll just write it out
                $('#myDiv').replaceWith(response);
            }
        });
    }
    

    And in your controller:

    public ViewResult BeginFooProcessing(String fooBar)
    {
        if (Request.IsAjaxRequest())
        {
            Guid fooId = Guid.NewGuid();
    
            var result = new FooResult
                            {
                                FooId = fooId,
                                HasFinishedProcessing = false,
                                Uris = new List<string>()
                            };
    
            // This needs to go to persistent storage somewhere
            // as subsequent requests may not come back to this
            // webserver
            result.SaveToADatabaseSomewhere();
    
            System.Threading.Tasks.Task.Factory.StartNew(() => ProcessFoo(fooId));
    
    
            return View("MyFooStartView", fooId);
        }
        throw new InvalidOperationException();
    }
    
    private void ProcessFoo(Guid fooId)
    {
        // Perform your long running task here
    
        FooResult result = GetFooResultFromDataBase(fooId);
    
        result.HasFinishedProcessing = true;
        result.Uris = uriListThatWasCalculatedAbove;
    
        result.SaveToADatabaseSomewhere();
    }
    
    public ViewResult CheckFooFinished(Guid fooId)
    {
        if (Request.IsAjaxRequest())
        {
            FooResult result = GetFooResultFromDataBase(fooId);
    
            if (result.HasFinishedProcessing)
            {
            // Clean up after ourselves
            result.DeleteFromDatabase();
    
                return View("MyFooFinishedView", result.Uris);
            }
    
            return View("MyFooFinishedView", null);
    
        }
        throw new InvalidOperationException();
    }
    
    private class FooResult
    {
        public Guid FooId { get; set; }
    
        public bool HasFinishedProcessing { get; set; }
    
        public List<string> Uris;
    }
    

    Hopefully that will give you a starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across this situation. In the hash1 first column is the key
I have come across this question several times, you need to do some performance
I have come across this problem in the past but never solved it. I
I have come across a situation where my program hangs, looks like deadlock. But
I have come across this Cocoa application (source code) that shows a main Window.
I have come across this great function/command . Colour to RGB, you can do
My co-worker and I have come across this warning message a couple times recently.
I'm learning objective-C and Cocoa and have come across this statement: The Cocoa frameworks
I'm reviewing my old algorithms notes and have come across this proof. It was
I have just come across this code: function test(){ //... if ( $profilerule ==

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.