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

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.

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.

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.

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.

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

Related

Deploying ASP.Net Project to Ubuntu server using Mono

I have developed an ASP.net 4.5 Project using Visual Studio 2013 and I am assigned to deploy it on our Ubuntu server.
Like what other tutorials said I need to use Mono to make this possible. I think I followed those steps but when I try to open the page, it gives me this error.
I had this exception when deploying my application, but to a Windows Server. The problem was that some dlls references pointed to my local assemblies. (example: System.Web.Http.WebHost was referenced to C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Http.WebHost.dll, so in the server this LoadException ocurred because this dll was missing.)
So the generic answer is: There is some dll missing. Compare the references in your project with the bin folder in the server. If there's some reference that points to local machine, change the property CopyLocal to true, so when you compile and publish the dll will be copied to the output directory.
I don't use Mono, but how this same problem ocurred to me in a Windows Server, may be the same problem with you in a Linux Machine.
If the probem persists, try to create a simple project, with just one page and a few dependencies just to see if the asp.net works fine in this server.

Could not load file or assembly 'System.Web.WebPages' Asp.Net Webforms Navigation

I recently installed the package [Navigation] to an ASP.Net 4.5 Web Application. While I am running it on my local machine [I have VS 2012 installed] it works fine, but when I deploy to the production server I am receiving the error: Could not load file or assembly 'System.Web.WebPages'. I have added references to Syste.Web.WebPages and Syste.Web.WebPages.Deployment but no luck.
You need to set the reference to copy local so that the dll appears in your bon folder or alternatively use the "add deployable dependencies" function in vs for a better way.
the problem is your production server doesn't have the library in it's gac so you need to provide it.
Do it this way, http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx however it is an MVC project but will work for you.

Where does ASP.NET look for binaries when you compile an ASP.NET 4 web project under x86 (32-bit)?

I'm developing an ASP.NET MVC 4/Web Api application in VS 2010 on my 64-bit dev machine. I have IIS installed and am running the project under IIS. Because I need to interface with a third party component, I have to change the project build configuration to x86 (I'm currently in the Debug build).
In IIS, I configured the application to use an application pool that allows 32-bit processes. However, when I ran my site, I noticed that code changes I was making were not showing. It turns out that the assemblies being used were those found in the \bin folder. After changing the configuration, the compiler's assembly output goes to the \bin\x86\debug folder; it didn't look like IIS was looking there.
I temporarily switched the configuration back to "Any CPU", right-clicked the project node, and selected the Clean option. This removed all the stale assemblies in the \bin folder. I then switched back to the x86 configuration -- rebuilt the project for good measure -- and tried to run the project again. Now it wasn't finding any assemblies at all. I'm getting errors like:
Could not load file or assembly 'System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies
System.Web.Providers -- and all the rest of the assemblies -- reside in \bin\x86\debug.
Is IIS supposed to know to look there?
Is Visual Studio supposed to copy the assemblies up two levels to the \bin folder?
If the latter, that is clearly not happening. Thanks for any insight.
The solution was simply to set the Output Path to bin in the Build tab of the project properties. :-)

Error message about existing

I'm using VS 2010 with ASP.net MVC 2.
I recieved a program that was completed and when I was debugging the program I recieve an error message.
"Error 4 The type 'System.Web.Routing.RouteTable' exists in both 'C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll' and 'C:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\lib\AspNetMvc\System.Web.Routing.dll' C:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\src\Chapter01\GuestBook\Global.asax.cs"
and
"Error 1 The type 'System.Web.Routing.RequestContext' exists in both 'c:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll' and 'c:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\lib\AspNetMvc\System.Web.Routing.dll' C:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\src\Chapter01\GuestBook\Controllers\AccountController.cs".
The program was converted into VS 2010 format.
What should I do?
// Fullmetalboy
When you convert a project from .Net 2.0/3.5 to 4.0 in VS2010 the web projects will prompt you to upgrade the framework to 4.0 but you will need to manually go into the project properties and upgrade class library projects and certain other projects manually in the project properties. So this type of error is probably caused by your web project referencing the 4.0 version of System.Web.Routing but a class library in your solution is still referencing the 3.5 version.
One of the projects in your solution is referencing a single type (RouteTable/RequestContext) in two different places. I always start with cleaning and rebuilding the solution, but if that doesn't fix it, you're going to have to check the project references and resolve it that way. If all else fails, try to make a new project from scratch and manually add the references and projects you need and then copy and paste your old code.
Someone copied the ASP.NET MVC source code into the "lib" folder of your application and either included that folder in the project (so it is getting built when you build your project) or he/she built it before you got it and referenced it from within the project. Now it is in conflict with the ASP.NET libraries that exist in default installation folder on the system 'c:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll'.
Since you're using the .NET 4.0 Framework, the library System.Web.Routing is ambiguous. Make sure you have referenced System.Web.dll (version 4.0) and remove the reference to System.Web.Routing.dll

asp.net mvc 2 method not found

When I run my asp.net mvc 2 site (shared hosting) I get the following error:
Method not found: 'Void System.Web.Mvc.DataAnnotationsModelValidatorProvider.
set_AddImplicitRequiredAttributeForValueTypes(Boolean)'.
In the bin directory I have System.Web.Mvc.dll version 2.0.50217.0
On my local dev machine it runs fine.
Is it possible that if the hosting provider has a different mvc 2 version installed it would cause this error?
The official System.Web.Mvc is version 2.0.0.0. It seems that you are using some custom built version - 2.0.50217.0 that might be missing this method. Try deploying your application without the assembly in the bin folder.
I think a better way would be to copy the ASP.NET MVC 2 dll into your code directory(where ever you put your dependencies) and reference it from there. This way you can avoid this type of errors if the hosting machine doesn't have ASP.NET MVC 2 installed on it.
Thanks all for your help,
A referenced project had a different version in the bin folder (even though I cleaned the solution and set also the that project to reference the dll in the dependencies folder, it still copied the one from the bin folder).
After deleting that one and rebuilding, redeployed dlls and it ran.

Resources