MVC3 and MVC4 in same solution - asp.net-mvc

I have refereed old questions and found that people face many issues after installing mvc3 and MVC4 on same machine.
My question is how is your recent experience for the same and how the mixture works for you guys.
I want to create one solution which will have four projects out of them two are MVC projects. One is MVC3 and another is MVC4.
Let me know your views on this.
Thanks,
Jigar

In short - there shouldn't be a problem. Once 3 & 4 are both installed, the two use different project templates and the references to the MVC assemblies are specifically targetted at the correct versions.
Beyond that, the web.configs of the two sites then determine the other assemblies that are used - and since they are seeded by the project templates they will be correct.
Now, if you were asking about having 3 & 4 in the same project, that would be another story. But then you wouldn't do that.
It's true there are a few known issues with the Razor editor and stuff like that - but none of those are show-stoppers and are almost certainly likely to have been fixed by the time v4 RTMs.

Related

Is there an official page for ASP.NET MVC Futures?

I am planning to integrate Mvc.Futures in my project, but am unable to find any official documentation for this library.
Official project page on nuget.org points to old asp.net project page on codeplex and even there is not so clear where information about Futures can be found.
I might be missing something, but would appreciate if anyone can give me pointers to the right place.
Thanks.
This is follow up on my own question:
I haven't found anything else related to Mvc.Futures after i posted this question, so i ended up using T4MVC which seem to get more love from MSFT than the Futures itself (lead developer of this template is MSFT employee David Ebbo).
We are using it quite successfully so far (more than 8 months) and i am pleased with the results.
For better integration with Visual Studio i am using AutoT4MVC extensions which runs the T4 templates on each change in the sections of the MVC app that require rebuild (such as Controllers, Content*, Views etc..)
To sum up - i would suggest that you stay out of Mvc.Futures for now and use T4MVC instead.

Portable modules in Asp.Net MVC 4

I have a module in my project that I want to share with another project in the solution. It consists of several controllers, models, and views.
I want to avoid seeing copy-pasted files.
I have done some research into this and seen some old solutions of portable areas using mvc-contrib. Does this work in MVC 4? Looks like it doesn't.
I've had a play with nuget and created a package, and it packages up the compiled stuff nicely but it copies the views into the project. What's to stop someone editing those views instead of updating the source project and repackaging?
Does anyone have a solution for this?
This is what I was looking for http://razorgenerator.codeplex.com/
See ASP.NET MVC Plugins......

Upgrading ASP.NET MVC1 project to ASP.NET MVC4

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?

possible to share views across multiple mvc 3 projects

I am building several different asp.net mvc 3 web projects all under one solution. I'd like to be able to utilize a few views across all of those projects as they're all going to be displaying the same thing on 2 or 3 different pages (with some custom stuff plugged in per the application).
Is this possible to do?
Only thing I can think of is to compile your cshtml into a separate assembly (assuming you are using RAZOR). See here.
Generally speaking I've not seen many examples of multi project ASP.NET MVC solutions. Because it kinda doesn't make sense. It complicates things, it disregards areas, which could possibly be used to get the same kind of experience but are far better option that multiple MVC projects. Then there's the question whether the 3 projects have so much in common that they really should all be in one solution. What kind of MVC applications do you actually have? What do they do? Most sample solutions online are single MVC project and multiple class library projects.
Now to the actual question..I recently found myself doing something similar, actually I didn't have multiple projects in one solution but I had different standalone projects that would all benefit from using the Views from one single, we could say the "master" project. I ended up creating Nuget package for it. I actually also injected other stuff into the package (scripts, styles, images, etc) but you could use it for Views only too. Then you just add the package to the next project and it inserts the files in the package into destination project. What I'm trying to say is, your package doesn't necessarily have to contain code.
I won't go into details here but you should look into it.

Registering Controllers using AutoFac in an ASP.NET MVC2 application with Areas

Has anyone been able to get AutofacControllerFactory working in applications where the controllers are split into Areas?
Looks like it is not supported out of the box in the current version.
Thanks
I'm afraid I can't offer a solution for AutoFac, but perhaps you could consider using Ninject (Github Download) instead? It does work with areas if you grab the latest Ninject MVC extension build from Github.
At the time of this posting there is a small bug in the MVC extension which sometimes causes types to get double-registered and results in controller resolution errors. The quick fix is to simply rebuild the application pool in IIS. Having spoken with the developer recently, it sounds like they've gotten the problem tracked down and it's just a matter of time before they update the sources.

Resources