Increasing timeout values ​​in ASP.NET MVC 3

I have a JSON service that I am viewing through ASP.NET MVC 3. This service appears as an action on the controller. I can successfully trigger an action. However, sometimes, an action takes too long to complete. Because of this, my caller fails due to a timeout. My question is: how to change the timeout threshold in ASP.NET MVC 3.

+4
source share
2 answers

If you need to perform some task, which, as you know, may take some time, it would be nice to use AsyncControllers, and you can set a different timeout between actions

eg

[AsyncTimeout(3000)] //timeout in miliseconds public void DoTaskAsync(){ //something that takes a long time AsyncManager.Parameters["result"] = contentresult; //Contentresult is your data result of process } public ActionResult DoTaskCompleted(String result){ return json(result); } 

http://msdn.microsoft.com/en-us/library/ee728598.aspx#Y4400 More details

otherwise ... HttpContext.Server.ScriptTimeout = 3000;

+3
source

It depends on the time. If this is just a server response, I believe that you can install it in the controller itself (in seconds):

 HttpContext.Server.ScriptTimeout = XXX; 

If it looks like a session or an authentication timeout, you will need to expand these values.

0
source

Source: https://habr.com/ru/post/1416453/


All Articles