3

I'm a relatively new C# developer, and I'm finding myself roughly 1/5th as productive building C# MVC applications in VS 2010 than I was doing it previous in Zend using php by hand using vim.

I work in an iterative cycle of write tests / write code / run tests / integrate & debug problems.

This last step involves building the code using visual studio, debug > attach to process > w3wp.exe and then visiting http://localhost/App/ (localy copy of IIS 7.5) and trigging some event/etc that kicks the VS debugger into running.

Upon finding a bug / issue I then stop the debugger, fix it, recompile and repeat.

This is unbelievably slow.

Compiling the application takes maybe 2 seconds, but the first time loading up in the debugger takes about 60-80 seconds. Turning the debugger off improves the speed of this fractionally, but not significantly.

There is nothing special about my copy of IIS; it's just configured to run locally serving the project directory from the visual studio project.

My machine isn't fantastic, its a 3.0Ghz duel core running windows 7 with 4 GB of ram... but this is just beyond a joke. I'm spending more time staring at my screen waiting IIS to do something than I am writing code.

Subsequent page loads are obviously really quick, you know instant page loads.

The issue, I guess, is that IIS needs to run application startup and load files and do whatever it does with the application pool worker when I recompile, which means the initial startup is slow (IOC, web config files, etc).

...and yet, I can't seem to find many other people on the net complaining about this, so I guess it must be some combination of how the application is configured, how IIS is configured and my workflow which are messed up.

What am I doing wrong?

If there's no way around IIS startup, how should I be doing development to avoid this problem?

2
  • Can you provide more information about your project, such as a rough estimate of # of code files, what it does, etc? If you had a hello world project, it shouldn't take more than a couple seconds for the CLR to JIT compile the app on first load. Since it's taking a minute for first page load, I'm thinking you've got something else going on, or some really horrible stuff running in the background. Aug 31, 2011 at 7:02
  • It's an unremarkable shopping cart web application. The only thing that is perhaps unusual is it has about 8 soap service dependencies (instead of a database). Solution currently stands at 8 sub projects, 8k loc. ~85 on maintainability index, cyclomatic complexity ~35?
    – Doug
    Aug 31, 2011 at 8:10

2 Answers 2

3

I think most people use the Built In Visual Studio Development Server (IIS-like). If you are running SP1 you can also use IIS Express which is more robust for larger and/or multi/cross website applications.

Right Click on your Web Application -> Properties -> Web Tab to select a Debug Server.

3
  • This is an option, but visual studio explicitly prevents you from exposing it to the network; so I can't use my mac to do cross platform testing as I work if I do this.
    – Doug
    Aug 31, 2011 at 8:13
  • For Visual Studio Development Server yes, but not for IIS Express. As a matter of fact, I currently setup a VirtualBox running XP with Visual Studio 2010 w/IIS Express running on a Mac. The Mac user is editing files on the XP box, and refreshing the web browser without issue. Aug 31, 2011 at 8:14
  • Nice. It cut the load time by about 50% using IIS express. Now its only ~30 seconds for the first page view.
    – Doug
    Aug 31, 2011 at 8:39
1

I agree with you, that it might have to do something with your local system. Obviously it's not possible for me to tell you how your system is missconfigured, but I would check that first in more detail.

Some other hints which might be helpful, even if they don't solve the root of the problem:

  • Use the build in development server as Erik proposes.
  • If you have only changed templates, you don't have to restart from scratch.
  • If you have good unit tests, you don't need to start the web application at all.
  • Does IIS 7.5 have app pools? If yes, you could restart just the app pool, which is much faster than restarting the whole IIS.

PS.: I have seen quite some strange behaviours when opening database connections, if the network is configured in a bad way. Even if it's on the local machine, you might have strange DNS lookups or something like that. Just as an additional hint about what to look for.

2
  • The debug work I have to do it very seldom in the templates (heh, that's what we have designers for..) its almost always in the controllers...and you can't unit test controllers as far as I'm aware. I'll investigate app pools, but I'm fairly sure this is already what IIS 7.5 does.
    – Doug
    Aug 31, 2011 at 8:16
  • You can unit test controllers, but it depends on your controller how tricky it is. If you make sensible usage of MVC features, it should be easy. What you describe sounds like your controllers contain way to much logic.
    – Achim
    Aug 31, 2011 at 9:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.