Upgrading ASP.NET MVC1 project to ASP.NET MVC4 - asp.net-mvc

I need to upgrade an application that runs on ASP.NET MVC 1 to ASP.NET MVC 4.
The new application still uses the Webforms Viewengine. It uses StructureMap for Dependency Injection.
If possible I would like to upgrade manually.
For upgrading from ASP.NET 1 to ASP.NET 2 I found the white paper
http://www.asp.net/whitepapers/aspnet-mvc2-upgrade-notes
The steps described in the document seem to be of little risk:
Fiddle with web.csproj
Replace Version=1.0.0.0 in web.config by Version=2.0.0.0
Reference System.Web.Mvc (v2.0.0.0) in the project
chnange bindingRedirect in web.config
update css and js files
What about upgrading to MVC 4: Will there be different steps involved?

You would follow a similar set of steps to upgrade to MVC 4. Microsoft has a whitepaper that outlines the steps required to manually upgrade a project from MVC 3 to MVC 4.
I have upgraded from 3 to 4 following these steps and it was a pretty simple and smooth process. Going from 1 to 4 is a bigger jump of course, so to minimize headaches you might want to individually upgrade 1->2, 2->3, 3->4: if you run into any breaking code changes it will be easier to identify how to resolve them. But fundamentally, all you're really doing is changing project GUIDs and referencing newer DLLs and such. It's not brain surgery.
To answer Ashok's question, MVC 4 is certainly deployable if you wish to use it today - my public blog is running it (on my own server). Use preview software at your own risk, of course.

My understanding is that MVC 4 is still in developer preview so a lot of features may and likely will change when the RC version is release. Since it is in dev preview is it even deployable as a live site?

Related

Upgrade MVC1 project to MVC5

Is there a way to convert a ASP.Net MVC 1 project build in VS2008 to ASP.Net MVC 5 and VS2015?
I tried to just open it in VS 2015 but that gave the error "This project is incompatible with the current version of Visual Studio".
There are ways to reference newer versions and update, eg:
http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
.. however updating from MVC1 (especially if you cannot open the project) you probably don't want to manually install ASP.NET MVC installs etc (if that what I remember)
I would suggest creating a new MVC5 application, referencing MVC via Nuget etc and pulling in code as required. This will give you a chance to re-structure things and learn newer ways otherwise you my be fighting with MVC configuration and references.

Issue with Visual Studio 2013, MVC 4.0 application and Web API 2.2 Nuget Package Install

I have a standard MVC 4.0 project for my application which was working correctly. I needed to use WebAPI within the same project so I installed the Nuget Package for WebAPI 2.2.
All seemed well and WebAPI ran fine after some tests, and my project also ran fine, except for the fact that now I cannot add standard MVC controllers, they all refer to adding a WebAPI controller and also options to add a standard view from an action inside a standard MVC controller using the Right Click context menu are now missing.
It seems as if it is assuming it is a WebAPI project only now, however I still need all MVC related options to be present. I am using Visual Studio 2013.
Any advice on this appreciated.
I believe it is not possible to use both WebAPI and MVC in the same project.
I managed to get it pretty much working using two projects in the same solution e.g. MyProject.MVC project and MyProject.API. However this turned out to be a bit clumsy, the biggest issue for me was getting Unity to work for both cases. Eventually I got that working too, but after a few days I figured I didn't actually need the WebAPI portion and it was causing more work than it was worth, so I removed that from the solution.
Not sure this answers your question tbh, but hopefully useful in some way. Btw in the next version of MVC6 (vNext) they are apparently planning to combine the Mvc and WebApi parts into a single framework, so this should ease the pain!

When is the mono implementation of mvc 5 expected to come out ?

Currently I am trying to figure out the architecture for a product revamp. The current project is in Asp.Net Webforms 4.0 but I am leaning heavily towards MVC 5 now. Problem is that a few customers (around 10%) do not want to get stuck with Windows Server licensing but our dev team/environment is .Net/Windows based. I was wondering if I could build it in MVC 5 leveraging the latest features like scaffolding, filtering, etc and also be able to port it to Linux based platform through Mono.
Does it sound realistic ?
I wanted to know about the timelines for a stable implementation of MVC 5 in Mono so that I can know whether I can depend on Mono when my team would be working on portability 2-4 months down the line. Otherwise MVC 5 may be a dealbraker for us.
I went through the Mono site and it links to StackOverflow for any questions ... so here I am
MVC 5 will likely never be 100% stable/supported on Mono, as it builds upon System.Web which Microsoft never open-sourced and is difficult to recreate in Mono. edit this may change now that the sources for System.Web have been made open source.
MVC 6 (and all the other stuff from ASP.NET "vNext") is a complete rewrite to get rid of System.Web and will support Mono out of the box, as Microsoft actively tests on it.
See http://www.asp.net/vnext, https://github.com/aspnet/Home and https://github.com/aspnet/Mvc.
My advice would be to keep an eye an ASP.NET "vNext" (it is in development stage right now, but will be the future of ASP.NET for the next decade) if you want to have proper Mono support. You can also start with MVC 5 now, but be aware that there will be breaking changes by the time you upgrade to MVC6.
You could also try Nancyfx, which is a MVC framework that has been built from the start to work with .net and mono.
I currently use it on a project. I develop on windows and .net and then publish(copy files) to Unbuntu and mono. Its very seamless.
Nancy's hosting support is very broad also.
Hosting Nancy with ASP.NET
Hosting Nancy with WCF
Hosting Nancy with Azure
Hosting Nancy with OWIN
Hosting Nancy with Umbraco
Hosting Nancy with Nginx on Ubuntu
Hosting Nancy with FastCgi
Self Hosting Nancy

What happens my asp.net mvc Project is using mvc 5 and mvc 5 is not installed on the server

What happens my asp.net mvc Project is using mvc 5 and mvc 5 is not installed on the server?
Does it take the closest one, if 4 is installed it takes that insead?
Install MVC 5 via Nuget. That gives you the binaries and puts a reference in your project. Then when you deploy your application everything needed will be included, and there is no need to install anything on the server.
No it doesn't take the closest one, unless you have a binding redirect, and this only works for lower versions not higher ones. You will need to reference mvc 5 in your project or put the assemblies in the GAC on the server.

Upgrading from MVC Preview 3 to Beta/RC

We have a web app that is using MVC Preview 3. I'm new to the project and relatively new to ASP.NET MVC itself - soon we will be looking to upgrade to either the Beta or RC version.
Are there any major difference between preview 3 and Beta version that would require extensive refactoring?
Any "gotchas"?
From my understanding the RC will be very close to the current Beta... does anyone have a view on this?
Any advice apprecited really.... thanks.
There were quite a few changes between preview 3 to the beta. IIRC the most pain came between preview 3 - preview 4.
One of the biggest gotchas is some of the functionality in the main dlls got placed into a separate dll because they were not going to be fully supported for the first release.
I suggest you brew a large pot of coffee and go and read everything Phil Haack and Scott Gu wrote around that time.
http://haacked.com/archive/2008/07/16/aspnetmvc-codeplex-preview4.aspx
http://weblogs.asp.net/scottgu/archive/2008/07/14/asp-net-mvc-preview-4-release-part-1.aspx
ASP NET MVC - Beta Release Notes has all the details regarding the changes. It is available at the mvc download page.

Resources