Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I forced to rebuild my project to see changes made to controllers in ASP.NET MVC?

I'm using ASP.NET MVC 3 Beta and for some strange reason, if I change a controller's action and load the action in a browser, it doesn't recompile the assembly to incorporate the changes made. Maybe I'm spoilt from how things were in ASP.NET Webforms, where there was dynamic on-the-flycompilation of code-behind files, but I think this should be possible.

I'm left wondering if maybe it's due to how my project is set up. I'm using VS2010 and compiling for 64-bit executables.

like image 390
Diego Avatar asked Oct 26 '10 18:10

Diego


2 Answers

In an ASP.NET WebForms Web Site Project, code-behind files were compiled on the fly.

In an ASP.NET MVC Web Application, the Controllers are pre-compiled assemblies which is why you need to build them each time a change is made. This is similar to how things worked in a pre-compiled ASP.NET WebForms Web Application.

You're not missing anything either. If you want .NET MVC, you'll have to live with compiling each time a change is made.

like image 129
Justin Niessner Avatar answered Sep 24 '22 13:09

Justin Niessner


For me, this is a lot nicer. The utility of deploying a .dll as opposed to a ton of C# source files outweighs the convenience of on the fly compilation. That, and you can't accidentally deploy C# code which doesn't compile this way either.

like image 24
Kevin Stricker Avatar answered Sep 26 '22 13:09

Kevin Stricker