21

I just updated my website from MVC 4 to MVC 5.

Now when I want to run it on my web server instead of my development machine it does not work.

It think it is because I need to install the MVC 5 libraries on the server but I can't find them.

I downloaded WebMatrix 3 hoping it would provide a way to install it but it only gives me the ability to install MVC 4.

What should I install to be able to run a ASP.NET MVC 5 application?

(without installing Visual Studio 2013)

EDIT: I disabled custom errors and eror what I have:

Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

EDIT 2: I found out that the problem was due to one of my dependencies which was using the version 2.0.0.0 of razor.

alexandrekow
  • 1,927
  • 2
  • 22
  • 40
  • We need more diagnostic information besides "it does not work". – Dai Nov 13 '13 at 20:10
  • When visiting the website I got the IIS server error page. Without error message. – alexandrekow Nov 13 '13 at 20:11
  • did you look at the Application eventlogs? Start > run > eventvwr – Ahmed ilyas Nov 13 '13 at 20:13
  • @alexandrekow Disable IIS (and ASP.NET) custom errors in your web.config file, then you'll get detailed error messages that should help. – Dai Nov 13 '13 at 20:17
  • MVC isn't something to be installed. It's just a set of dll that needs to be in the bin folder. Like Dai said, you need to get the specific error message. It might be something completely different than what you think is hapenning. – the_lotus Nov 13 '13 at 20:33
  • I added the error message. I looked in the web.config and all Razor reference targets Version=3.0.0.0. Could it be because of Elmah? – alexandrekow Nov 13 '13 at 20:36

4 Answers4

17

When you deploy your app just make sure that all the assemblies are being deployed to your production environment in the bin folder. ASP.NET MVC is an xCopy deployment, so you don't have to install anything.

You might want to check that your Production environment has ASP.NET 4.0 and 4.5 registered.

Khalid Abuhakmeh
  • 10,709
  • 10
  • 52
  • 75
  • Ok thanks. I remember having to install MVC 3 to my web server once. So I guess the application would look in the GAC if the dll is not found in the application bin folder. – alexandrekow Nov 13 '13 at 20:47
  • How would one check to see if ASP.NET 4.5 was registered? – Bryan Legend Apr 08 '14 at 19:05
  • 2
    The easiest way is just to re-register .NET with IIS. It is quick. I would check in Control Panel to see if you have **Microsoft .NET Framework 4.5** installed. Then use regiis like you normally would. http://stackoverflow.com/questions/13749138/asp-net-4-5-has-not-been-registered-on-the-web-server – Khalid Abuhakmeh Apr 09 '14 at 13:50
  • What does "check that your Production environment has ASP.NET 4.0 and 4.5 registered" entail? I went to Control Panel -> Programs and Features- > and see .NET 4.5.2 and .NET 4.6. What more do I need to look for? – John Zabroski Jun 17 '16 at 13:08
3

MVC5 and future version of MVC doesn't require to installed on Windows Server. MVC5 app have everything as packages. You didn't need anything to install it.

What is required on server is copy of every library and assembly that you have used in your app. For fix this, Just make sure that everything on your bin folder is called same on server instead of server is looking for it's own GAC for assembly used in your app.


If you didn't found all the packages then you can install nuget packages on server by cmd.

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79
  • This is a helpful clue, but I am getting this error despite NuGet using Microsoft.Owin 3.0.1 and Web.config redirecting to 3.0.1: Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) – John Zabroski Jun 17 '16 at 13:05
  • @JohnZabroski Your Bin folder does contain different version then the one written in web.config. If you are not sure remove specific version string from the web.config and try it. – Anirudha Gupta Jun 17 '16 at 13:17
  • Is it possible the problem is I have .NET Framework 4.6 installed in the target environment, but in my Visual Studio Solution, I targeted 4.6.1? – John Zabroski Jun 17 '16 at 13:50
  • @JohnZabroski The .NET Framework should not be newer in production environment, no matter small or big update. If you target 4.6.1 in Development you must have it in production server too. – Anirudha Gupta Nov 21 '16 at 10:56
2

The best is to do a Publish, right click on your project in Solution Explorer and select 'Publish'. Basically it will compile your solution and dump all the assemblies/artifacts to either your webserver, ftp or a local folder.

Duy
  • 1,332
  • 1
  • 10
  • 19
0

Make sure all your assembly references are being copied to the deployment directory. To do this you can change the <Reference...> tag in your .project file. Optionally, you can use visual studio's property setter to set the "Copy Local" property of each dll reference to "True".

raminjacobson
  • 465
  • 1
  • 5
  • 8