tags:

views:

178

answers:

2

I'm wondering if anyone has any insight into why ASP.NET MVC sites have to be created as a web application (compiles to single .dll) in Visual Studio as opposed to a web site (each page is a .dll)? I suspect that it has something to do with the routing. Any thoughts?

+1  A: 

Web Applications have a .csproj file which gives a lot better control over the build process when compared to a Web Site project which is really just a set of files and folders with build managed entirely by the VS IDE as far as i'm aware.

You may be right about the routing, but another possible reason relates to project structure and the relationship between the MVC application project and it's test project.

One of the key differences between a Web Application and a Web Site is that the Web Site is a standalobe entity, it does not exist within a solution which makes it difficult to express the relationship of the test project to the application project, whereas if a web application is used then the web site and it's tests can be treated as two projects within a common solution while also getting all the benefits of using MSBuild

Crippledsmurf
A web app also just creates a class library assembly, which is easy to reference, whereas a web project only has the assemblies ASP.NET dynamically creates -- which change names with each reload and thus are rather hard to work with.
Richard
+1  A: 

Okay, I figured this out. The only reason that the ASP.NET MVC application is a Web Application instead of a Web Site has to do with the unit tests. You can 'convert' an ASP.NET MVC application to a web site with very little changes, but the unit tests won't work because they have no reference to the web site. But, I'm pretty sure that you can get the unit tests to work if you start pulling your application logic (controllers, et al) into a separate class library and then reference that class library in the web site and unit tests.

Peter Mourfield