ASP.NET MVC Debugging Very Slow - SQL Server Expre

2019-09-22 08:31发布

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?

3条回答
叼着烟拽天下
2楼-- · 2019-09-22 08:56

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

查看更多
叛逆
3楼-- · 2019-09-22 09:00

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.

查看更多
放荡不羁爱自由
4楼-- · 2019-09-22 09:15

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.

查看更多
登录 后发表回答