How to install ASP.NET MVC 5 on a server?

2019-03-24 12:52发布

问题:

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.

回答1:

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.



回答2:

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.



回答3:

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.



回答4:

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".