Commands issued by the application framework use a default timeout of 30 seconds. When necessary, this timeout can be changed to fit application requirements.
Let’s change the default command timeout to 5 minutes.
Start Code On Time web application generator, and click on the project name. Then, click on Develop option. The project will be opened in Visual Studio.
In the Solution Explorer, right-click on ~\App_Code folder and press Add | Add New Item.
Select Class from the list and press Add to create the file. Replace the code with the following:
public partial class Controller
protected override DbCommand CreateCommand(DbConnection connection)
DbCommand command = base.CreateCommand(connection);
command.CommandTimeout = 60 * 5;
Partial Public Class Controller
Protected Overrides Function CreateCommand(connection As DbConnection) As DbCommand
Dim command As DbCommand = MyBase.CreateCommand(connection)
command.CommandTimeout = 60 * 5
Save the file.
Let’s make sure that the application uses the new command timeout. Place a breakpoint at the last line in the method, and press F5 key to run the web app.
Navigate to any page that has a data view. The application will stop at the breakpoint. Mouse over the command timeout property – the value will now be “300”.