1

My stored procedure takes 42 seconds to execute . My web application gets timeout after 30 seconds. i have added:

< httpRuntime targetFramework="4.5.1" maxRequestLength="157286400"   
  executionTimeout="36000" />

in my system.web in web.config file. I also added Connect Timeout = 300000 in my connection string of the web.config.

enter image description here

But none of the solutions works for me. I tried to clear the SQL Server deadlock by executing below commands :

exec sp_updatestats

dbcc freeproccache
8
  • You need to make sure that Is your server giving you timeout while executing store procedure or your HTTP request is timeout? Commented Apr 5, 2018 at 7:27
  • did you try to increment commandTimeout for Stored procedure? Commented Apr 5, 2018 at 7:28
  • How may i know is it timeout in SP or HTTP request? Commented Apr 5, 2018 at 7:30
  • i did not added commandtimeout in my SP Commented Apr 5, 2018 at 7:31
  • 1
    Remember that .NET has a different execution plan than SSMS for the same Stored Procedure. Have you tried setting the timeout in your Model.Context.cs? Try doing this, stackoverflow.com/questions/10549640/… Commented Apr 5, 2018 at 8:25

1 Answer 1

0

By default, many frameworks set the command timeout to 30 seconds, so if your query takes around 40 seconds, it'll run fine in SSMS but not in code. for EF

            context.Db.Database.CommandTimeout = 60; // Timeout in seconds

            var sqlQuery = @"exec spRunt ";

            return context.Db.Database
                .SqlQuery<DataType>(sqlQuery)
                .ToList();

For Ado

 SqlCommand command = new SqlCommand(query, connection);
command.CommandTimeout = 60; // Timeout in seconds
Sign up to request clarification or add additional context in comments.

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.