asynccontroller

AsyncController's async action blocks requests instead of returning immediately

痴心易碎 提交于 2019-12-13 02:57:20
问题 This is the first time that I am using AsyncController (MVC3) and I am having trouble understanding the asynchronous action. My task is to import moderate amount of data from Excel to SQL Server database, using Entity Framework. I thought this would qualify for an async operation and so I wrote a controller explicitly for that purpose. Here is the controller code with async Action public class CampDonorImportController : AsyncController { public void CampDonorImportAsync(string fileName, int

Building unit tests for MVC2 AsyncControllers

安稳与你 提交于 2019-12-09 15:14:31
问题 I'm considering re-rewriting some of my MVC controllers to be async controllers. I have working unit tests for these controllers, but I'm trying to understand how to maintain them in an async controller environment. For example, currently I have an action like this: public ContentResult Transaction() { do stuff... return Content("result"); } and my unit test basically looks like: var result = controller.Transaction(); Assert.AreEqual("result", result.Content); Ok, that's easy enough. But when

Best way of handling timeouts with AsyncController

▼魔方 西西 提交于 2019-12-06 10:13:25
问题 I have a long time polling controller in my MVC3 project. It has its timeout set to 30 seconds. I have a HandleErrorAttribute implementation that handles logging of all errors. Since the timout throws a TimeoutException it means these will be presented in the log. I need to intercept this error before my HandleErrorAttribute class gets it and return a json object instead of the 500 error page. Whats the best approach for this? I did this and it works public class HandleTimeout :

Async operation completes, but result is not send to browser

与世无争的帅哥 提交于 2019-12-05 02:19:05
问题 I want to implement a webchat. The backend is a dual WCF channel. Dual channel works in the console or winforms, and it actually works on the web. I can at least send and receive messages. As a base I used this blog post so, the async operation completes. When i debug the result, I see that the messages are all ready to send to the browser. [AsyncTimeout(ChatServer.MaxWaitSeconds * 1020)] // timeout is a bit longer than the internal wait public void IndexAsync() { ChatSession chatSession =

Best way of handling timeouts with AsyncController

南笙酒味 提交于 2019-12-04 16:44:55
I have a long time polling controller in my MVC3 project. It has its timeout set to 30 seconds. I have a HandleErrorAttribute implementation that handles logging of all errors. Since the timout throws a TimeoutException it means these will be presented in the log. I need to intercept this error before my HandleErrorAttribute class gets it and return a json object instead of the 500 error page. Whats the best approach for this? I did this and it works public class HandleTimeout : HandleErrorAttribute { public override void OnException(ExceptionContext filterContext) { if(filterContext.Exception

Can ASP.NET MVC's AsyncController be used to service large number of concurrent hanging requests (long poll)?

对着背影说爱祢 提交于 2019-12-03 10:08:37
问题 Frameworks like Node.js, Tornado, and Twisted let developers create server-push applications that supports large number of concurrent hanging requests (10k+). From what I understand, they all achieve this by not creating threads to service each hanging request. Can AsyncController be used to service large number of inactive concurrent requests? If so, are there any reasonably large ASP.NET MVC websites using this approach to create long-poll applications? 回答1: I recently wrote a simple

Implementing a Progress bar for long running task implemented with an ASP.NET MVC 2 AsyncController

最后都变了- 提交于 2019-11-27 19:08:51
After reading the documentation on AsyncControllers in ASP.NET MVC 2, I am wondering what's the best way to implement an ajax progress bar in this scenario. It seems a bit odd that the tutorial does not cover this at all. I guess implementing an AJAX progress bar involves requires additional action method that returns the status of the current task. However, I am not sure about the best way to exchange information on the status of the task between worker threads and that action method. My best idea so far was to put information on the curent progress into the Session dictionary along with a

Implementing a Progress bar for long running task implemented with an ASP.NET MVC 2 AsyncController

醉酒当歌 提交于 2019-11-26 19:46:01
问题 After reading the documentation on AsyncControllers in ASP.NET MVC 2, I am wondering what's the best way to implement an ajax progress bar in this scenario. It seems a bit odd that the tutorial does not cover this at all. I guess implementing an AJAX progress bar involves requires additional action method that returns the status of the current task. However, I am not sure about the best way to exchange information on the status of the task between worker threads and that action method. My