views:

377

answers:

9

I used to just upload asp.net websites to the live server, and IIS compiles them automatically.

But when I do the same with asp.net MVC projects I just get errors, and I need to release Build the project before I upload it.

Note1: I'm using VWD 2008 Express

Note2: The project is working perfectly if I release build it on my machine then upload to the server

+1  A: 

With mvc you can do a "publish", this will place in a directory of your choosing all the files you need to copy up and the directory structure they should be in. Note that in mvc all c# files are pre compiled into a dll in the bin directory and are not then compiled by IIS. All your other "web" files: aspx, css etc files will still be in their normal format. But if you do a publish and then copy that directory up you should get everything.

I am assuming that the error you are getting is due to the fact that you are not copying up all the required files and without additional information it will be hard to narrow it down exactly.

Dean Johnston
I'm copying the whole project, but if I dont do build before upload it won't work... is there a way to get IIS to compile the C# files ?
Ahmed Khalaf
+1  A: 

As noted, you need to build the project before deploying it. In addition, are you sure that ASP.NET MVC is installed on the server?

Wyatt Barnett
asp.net mvc doesn't need to be installed on the server, the DLLs need to be copied to the project before being uploaded to the server
Jimmy
If you are doing things right--ie, putting common core assemblies in the GAC, it does need to be installed. But yes, you can get away with deploying the DLLs with your solution.
Wyatt Barnett
Wow, a bounty added to a question that already had the correct answer way back in October!
Charles Boyung
A: 

I believe you might be missing a reference to the System.Web.Mvc assembly in your Web.config file on the IIS. Make sure that this assembly is referenced in the Web.config file.

You will also have to make sure that this assembly is available to IIS. I think it is a strongly-named assembly, so it can be added to the GAC (Global Assembly Cache) on the machine running the IIS. This last bit is especially important if the development machine and the deployment machine are two separate machines.

Umar Farooq Khawaja
A: 

The question is, what is the difference between your local environment and the production environment? Are you using any sort of (pre- or post-) build step, like Javascript minimization?

Matt Sherman
+1  A: 

Try this and see if it works. (Or just ensure the server your deploying to has ASP MVC installed)

  • Expand your projects References folder
  • Right click on the System.Web.Mvc dll and select properties.
  • Select True from the drop down for Copy Local. This will copy the ASP MVC dll to your bin folder when you do your build / package.
Justin
+2  A: 

It boils down to the project model. Asp.net MVC only works with project files (not the folder approach), so you really have to build it to publish it (which can be using the publish feature and copying All in there - including the bin folder).

You probably could get around it by adding some automation that invokes the compiler, but its just designed for you to upload the assembly for the .cs files you had. Related to this approach would be to include continuous integration to your efforts, or maybe just borrow the piece that takes care of doing the build.

Note: I'd argue that the folder based model for asp.net has less time around than the project based one i.e. since the first versions of asp.net project file based model was the one used, when vs 2005 was introduced they changed to the folder based model and then added the project file one again. Check the link for info on the project file model.

eglasius
A: 

I had a similar problem, and it turned out to be that the server didn't have ASP.NET MVC installed. Once I copied over the MVC dlls into the bin directory, it worked just fine. Are you sure the MVC dlls are available on the server? Try copying them over with your project and see if it works.

adimauro
A: 

Does the server you are trying to upload to have the System.Web.Mvc dll?

Seattle Leonard
+1  A: 

Charles Boyung's comment should have been considered as an answer.

MVC applications are like Web Projects, not Web Sites in Visual Studio - they must be compiled before deployment. –

Being not compiling on the server is one of the difference points between Web Application Projects (WAPs) and Web Site Projects (WSPs)

http://vishaljoshi.blogspot.com/2009/08/web-application-project-vs-web-site.html

Q1. Do you intend to deploy source code on your production server and edit it right on the server if there was a time sensitive bug reported ?

If you answered Yes to the above question, you want to use Web Site projects (WSPs)… In case of Web Site projects Visual Studio does not really compile your source code on your dev box, it merely uses aspnet_compiler to validate that your source code will actually compile and run on the server… Hence when you try to deploy a web site people typically also deploy the source code on the server which allows them to edit the source right on the production server if there was a time sensitive bug reported

Ahmed Khalaf
agreed with Ahmed Khalaf
Weixiao.Fan