Reputation: 4008
I have a JSON service that I'm exposing via ASP.NET MVC 3. This service is exposed as an Action on a Controller. I can successfully call the action. However, occasionally, the action takes too long to complete. Because of that, my caller fails due to a timeout. My question is, how do I change the timeout threshold's in ASP.NET MVC 3.
Upvotes: 4
Views: 3245
Reputation: 1620
If you need do some task that you know can take a little while would be nice use AsyncControllers, and you can set diferent timeout betwen actions
for example
[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 for details...
otherwise... HttpContext.Server.ScriptTimeout = 3000;
Upvotes: 3
Reputation: 14219
It depends what is timing out. If it's just the server response, I believe you can set it in the controller itself (in seconds):
HttpContext.Server.ScriptTimeout = XXX;
If it's something like the session or authentication timing out you will need to extend those values.
Upvotes: 0