4

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.

1
  • Are you sure that it isn't the calling agent that is throwing the timeout exception? Commented Jun 6, 2012 at 19:39

2 Answers 2

3

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;

Sign up to request clarification or add additional context in comments.

1 Comment

Are there any settings I can make in the web.config to handle this globally?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.