---
title: "How Asynchronous Controllers work in asp.net MVC?"  
description: "How Asynchronous Controllers work in asp.net MVC?"  
author: "Pedro Araez"  
published: 2020-02-03  
updated: 2020-02-03  
canonical: https://www.mindstick.com/forum/155773/how-asynchronous-controllers-work-in-asp-dot-net-mvc  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# How Asynchronous Controllers work in asp.net MVC?

[Briefly explain](https://www.mindstick.com/forum/156854/briefly-explain-the-concept-of-constructor-overloading) to me about how should we work with [asynchronous](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) in [asp.net MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) with example.

## Replies

### Reply by Nishi Tiwari

A working of **Asynchronous Controllers** is used when users send a request to Asynchronous Controllers the [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) will provide a thread from Thread pool to handle the request. The request is small then it will process it in normal way but in case if the processing is taking too long time to complete then it will return the process to **[thread pool for handling](https://www.mindstick.com/forum/155773/how-asynchronous-controllers-work-in-asp-dot-net-mvc)** other request and whenever the asynchronous operation will complete, it notifies ASP.NET then asp.net gets a worker thread from the thread pool to process the remaining of the request, which includes rendering the response.

A convention required for following when using Asynchronous Controllers. For Asynchronous Controllers we have two methods:-

## 1. Async

## 2. Completed

## Async

The async method will return void and it will start the asynchronous process. The syntax of the async method in asp.net [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) is shown below

```
Action Name Async
```

## Completed

The method is called when the asynchronous process is complete. The syntax of the Completed method in asp.net MVC is shown below

```
Action Name Completed
```

We will learn both these methods in detail with an example. In this example we used web service (Weatherservice) in IndexAsync method in that we created a proxy client which will take Country name as an input and will Return Cities then we will store cities in TempData["ListofCities"] when process will complete then it will call IndexCompleted() Method from which we will display result on view.

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcAttribute.Controllers
{
public class Default2Controller : AsyncController
{
public void IndexAsync()
{
Weatherservice.GlobalWeatherSoapClient objservice = new Weatherservice.GlobalWeatherSoapClient();
TempData["ListofCities"] = objservice.GetCitiesByCountry("India");
}
public ContentResult IndexCompleted()
{
string Result = TempData["ListofCities"].ToString();
return Content(Result);
}
}
}
```

![How Asynchronous Controllers work in asp.net MVC?](https://www.mindstick.com/mindstickforums/12f80d03-2c91-4f86-9679-cb6733ffc085/images/071ae85a-6bfa-497d-9c99-f0a60a40a1dd.png)\


---

Original Source: https://www.mindstick.com/forum/155773/how-asynchronous-controllers-work-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
