views:

413

answers:

3

I am developing an application in ASP.NET MVC, using SQL Server Express as the backend and Cassini as the development web server (the one that comes with Visual Studio 2008).

The application performance is blazingly fast (nearly instantaneous page switches). However, spinning up the debugger is painfully slow; it takes about 30 seconds from the time I hit F5 to the time the ASP.NET welcome page comes up.

I have noticed a similar delay when loading SQL Server Management Studio Express, and another delay when I open a table in my database for the first time for viewing. After I open my first table, everything goes smoothly.

Given the behavior of SQL Server Management Studio Express, I suspect that the problem lies in making the initial connection to SQL Server Express. Is this really where the problem is, and if so, how can I fix it?

A: 

I'd check the auto_close property on the database.

sp_dboption 'MyDatabaseName', 'autoclose'

I think the default on express might be to set autoclose to on. When that is set to TRUE, the server will close the database and free all resources from it when there are no users in the database. Setting autoclose to FALSE will tell the server to hang on to the database so that it's in the ready state regardless of users being in the database or not.

See here for more info.

Scott Ivey
It was set to false.
Robert Harvey
+1  A: 

If it's only slow when debugging, then there are several chokepoints to consider:

  1. Applications start off slower when debugging because of the precompilation the JITer has to do whenever the assemblies are rebuilt.
  2. If you're compiling and debugging every time, it may be your compilation that's slow, not so much your application performance. How long does it take for the browser to appear once you hit F5? If you have multiple projects in your solution, building them will take time. Try setting up a build configuration that excludes class projects (make sure to rebuild them manually when necessary)
  3. I haven't had any trouble with Cassini, but you might try IIS just for grins.

Just a few thoughts, HTH.

Dave Swersky
Dave, the browser appears instantly after hitting F5, and sits in a blank white state for the 30 seconds while the first page decides to appear. I generally build before hitting F5. I can try IIS7, but I will need to stand up another machine with Windows Server 2008 first. The solution is pretty small, and doesn't include any other class projects except the test project.
Robert Harvey
A: 

I finally solved the problem by rebuilding my TCP/IP stack, using Netshell from a Command Prompt window. Apparently I was getting a TCP/IP timeout.

netsh int ip reset c:resetlog.txt

http://support.microsoft.com/kb/299357

Robert Harvey
The link provides a tool "Microsoft Fix it" which as it says will fix the problem automatically but requires a restart.
Cedrik