Downgrade asp.net Mvc from 3 to 2 - c#

I know this is a rather odd question, please don't flame me :)
I have a concrete need to "downgrade" a current Asp.Net Mvc 3 (net framework 4) application to Asp.Net Mvc 2 (net framework 3.5) because our shared hosting provider does not support .Net 4 (I know it's crazy considering it's been in retail since 12 Aprli 2010 and first beta came out in May 2009 but it's not the point of the post).
Is there any tool, or guide, or anything that could help in the process? I'm getting a bit lost because I upgraded many applications but I never had to downgrade one.
Besides strictly MVC, I'm using a data layer with EF Code First (maybe nhibernate will be the best tool to replace that?)
Any help, tip, info, whatever is appreciated.
Thanks.
EDIT: Changing hosting provider is not an option, otherwise I wouldn't have posted this at all. I personally am against this downgrade - I find it totally senseless - but still it's the only option.

I would change hosting provider. If your provider is not supporting .NET 4.0 now then do you really want to build a long term relationship with them? What happens the next new great feature is released, how long will they take to implement that? I don't think there's any future there if that's the kind of service they provide.
Saying that, if you have no choice but to remain with them, then I think your only option is to
Change the project's target framework setting in Visual Studio to 3.5.
Remove MVC 3 and add MVC 2
Change all Razor views to the Web Forms view engine syntax
Recompile and work through all the errors
For your web.config file I would create a new MVC 2 project and work from that web.config copying any extra settings needed from your old config.
Depending on the size of the project this is obviously going to a be a big task.

The only way I can think of is to get a machine with MVC 2 installed, get the project and try to compile it targeting .NET 3.5.
This will generate lots of errors.
Actually - this might be the way to convince those that hold the purse strings that you need to change hosting provider. You can show them the error list and put an estimate on how long it will take to fix them. If this is a long time (a couple of weeks?) then it might be more cost effective to move.

You can convert asp.net 4.0 website to asp.net 2.0 easily
Just make a new website
Then Select .net Framework 2.0
Copy the all files except web.config file from your asp.net 4.0 website folder in the new website folder
remove the unused usings from all the .vb or .cs files
Run the website easily

Related

How can I slowly migrate a project from ASP .NET WebForms with VB .NET to MVC C#?

At the moment I have a legacy website written in vb .net and web forms. Its about ten years old. I want to start to migrate components of it over to C# MVC.
My plan is to create a separate project in the solution in C# with .NET MVC, and do all the controller code etc in there. I would need to wire up routing etc from the vb.net project though, into this project. Eventually over time the plan is to migrate the entire project over to C# with .NET MVC.
The app uses forms auth (albeit a bit of a hacky implementation of it), so if someone logs into the legacy app, their authentication should also be recognised in the "new" project/system.
How would I do this?
EDIT: There is stuff taped into code behind en masse (mainly on row data bound etc for gridview formatting) plus a gigantic class that does absolutely everything. Architecturally its about as bad as you could hope for.
As an initial step, you can convert your VB project into C# using SharpDevelop. They have independent IDE and also Visual Studio plugin.
Even though you stated that you don't have time to start a new project due to time constraints, this is the best route as you will spend more time converting code than working on a new project.

Is it at all possible to migrate ASP.NET ASPX solution to ASP.NET Core 2.0?

I want to migrate my asp.net (UI ASPX pages WebForms) application to ASP.NET Core 2. By some search I found out aspx is not supported in .net core. If this is true(anyone has exact documentation for this?) how should anyone proceed to convert from pure asp.net aspx project to asp.net core 2.0?
I used portable analyzer tool but it is confusing to just give every .dll file and get report which is more confusing.
Please give valid Microsoft document if possible.
It all depends on what you mean by "migrate". As mentioned in the comments to your question, ASP.NET Core does not support web forms so there isn't any way to just automatically convert an a Web Forms website to an ASP.NET Core website.
That said, it is possible to make the migration. I have been working to do just that for a very large web forms based website that I want to convert to ASP.NET Core. If you are serious about making the journey, then here is some info that will probably help you.
The general architecture of ASP.NET Core is based on MVC so it's much more similar to ASP.NET MVC than ASP.NET Web Forms. So you will end up rewriting pretty much all of your UI code using some derivative of a MVC pattern. Instead of master pages you will be using layouts. Instead of server controls you will be using tag helpers. Instead of user controls you will be using partials and view components. Instead of code behinds you will be using controllers and view models. Etc.
It's worth noting that there is still an http context object, request object and response object and they are extremely similar to the analogous objects in web forms. So that helps with the conversion.
Also to make the conversion process easier, you can build an ASP.NET Core web application that targets the full framework. This means that you will have access to most everything you are use to in the full framework except anything in the System.Web namespace. Targeting the Full framework does mean that your new website will only run on windows. But if you can live with that (at least for now) it will make the conversion process easier for you.
If, in your old website, you broke out a bunch of the functionality into class libraries, that will make your life easier. You should be able to bring those class libraries over to the new website unchanged and reference them from the ASP.NET Core website and they will most likely work fine provided they don't reference System.Web. Any code that does reference System.Web will need to be modified to use the new analogous objects or UI approaches.
So in the end, you may be able to bring over your data models, data access code, business objects, and business logic without too much hassle. But you will have to do a total rewrite of your UI related code. That's the journey I'm on and it's not as hard as you might think, at least not once you get up to speed with ASP.NET Core in the first place. Go get `em!
I found an article claiming that it's possible somehow.
As you know it's not easy to migrate entire project from WebForm to .Net Core instantly. So what if I be able to have my web form pages working on production and at the same time start to convert pages one by one gradually? I mean there are the combination of two approaches at the same project.
It's the idea that an open source named DotVVM proposes. You have your ASP.Net web form pages and merely install DotVVM through Nuget. DotVVM supports both approaches. DotVVM contains similar controls like GridView, Repeater, FileUpload and more, you need to know about DotVVM syntax though.
DotVVM can run side-by-side with other ASP.NET frameworks (Web Forms, MVC, Razor Pages)
it's claimed that:
If the business layer is separated properly, rewrite on one page takes about 1 hour in average.
After a few months (if your project is large), when all the ASPX pages are rewritten in DotVVM, you will be able to create a new ASP.NET Core project, move all DotVVM pages and viewmodels into it and use them with .NET Core. The syntax of DotVVM is the same on both platforms.
Here you can see five steps needed for the migration.
You can transfer all your business logic, models and even some controller methods (You just need to adjust those ActionResult to IActionResult). If you're using Ninject (for ASP.NET Framework IOS), you just need to register them to your Startup.cs. Basically, what I'm trying to say, you need to create a new application under .NET Core. It would be changes in the actual project solution, but your actual business flow won't be different. I hope this helps you.

Adding existing Node Js project to Existing .Net Solution

Updated.
Updated the question since it looks little ambiguous and not the answer i was looking for.
We have a huge .NET application running on MVC and angular. It has multiple projects under the main solution. .
We also have a replica of that application in Node.js for front end developers.
It looks something like this :
What happens is - Front end developers make changes in Node js solution (like js or .less files or controller) - make changes and move those changes to .Net solution which is the actual live project.
Off late - we have issues with developers working with two different solutions (Node and .NET) and keeping two copies of assets everywhere.
We ultimately decided to combine them and bring the whole Node.js application into ours .NET Solution as 6th project.
Something like this
Wondering if anyone has previously done so - adding a .NET application with existing Node.js application. If so any pros and cons to consider.
Some points to note - the Nodejs project and .Net project are completely independant of each other. The idea is to consolidate the applications so that We can either run the .net application or UI application from single solution.
Eventually, we will consolidate all the assets to just one project so that - we dont have to do duplicates.
Also, would appreciate any links where I can see how to start merging these two applications.
You definitely want to look at JavaScript Servcies. Building Single Page Applications on ASP.NET Core with JavaScriptServices.
Made for .NET Core, but you can run .NET Core on Full .NET Framework, which should make it easier to migrate to.
What I think you have is, say, a production version in .NET and a development environment in node.js for developers which prefer that.
At the company I work for, we use AngularJS for our front end and .NET/Entity Framework back end and it works pretty well.
I'm not sure if you are integrating some sort of JavaScript back end in with it or not. Assuming you are going to stick with a .NET backend and a JavaScript heavy frontend, it should be fairly easy.
That being said, nothing in this career is truly "easy". I would recommend using an AngularJS frontend as it has seemingly endless functionality.
Some minor suggestions if you choose that route is to check out John Papa's style guide. great reference for writing AngularJS. Make sure you have consistent naming, especially in Visual Studio as AngularJS can be a little moody.
I prefer to bind values to the view when working on AngularJS, e.g.
vm.title = "Data I want to bind"; in the view: <h1>{{vm.title}}</h1>
If that renders as {{vm.title}} instead of Data I want to bind you know something isn't working. I prefer catching it sooner rather than later.
Dependency Injection is another thing to be careful with, the style guide covers it as well. Basically if you minify your AngularJS files and the minifier removes the information required for DI, your project will break. I've been down that rabbit hole a few times.
If you aren't intending on using AngularJS then forget I said anything. I was just exercising my fingers. I hope that helps shed a little light on your decision.

VS2015 MVC No compile experience

It was my understanding that with the new compiler it is possible to run code without restarting an ASP.NET MVC project, e.g. the no-compile experience.
For example changing the model or controller requires restarting the entire project, which can take quite some time in VS2013 (especially with Code First).
Is this, basically edit&continue for ASP.NET, now possible in VS2015? I tried CTP5 but could not get this working.
Edit: The actual question
Does VS2015, or will it, support edit and continue or a similar experience (not having to restart for model/controller changes) for ASP.NET MVC?
Does VS2015, or will it, support edit and continue or a similar experience (not having to restart for model/controller changes) for ASP.NET MVC?
Visual Studio Edit and Continue is available and works for ASP.Net all the way back to version 2010 with constraints (IIS Express etc...).
Is this, basically edit&continue for ASP.NET
No. Scott Hanselman did a very detailed explanation of all the new features in vNext in this blog post Introducing ASP.NET vNext.
Excerpt:
One of the great aspects of environments like node or rails is that they are "no compile." Just change some code and hit refresh. With the next version of ASP.NET you get the power and throughput of the .NET runtime plus the "Roslyn" compiler-as-a-service for a "no-compile compile." That means means during development time you can just change your C# classes and hit Refresh in the browser. It's the power of .NET with the dynamism of a refresh-and-go development experience.
and
NOTE: This isn't ASP.NET Websites, or Razor View compilation - this is the whole thing, compiled in memory. You can use Visual Studio for development, or text editors like Sublime, or freakin' Notepad. (Of course, if you want assemblies on disk, you can do that too.)
and
See my web app’s bin folder in the screenshot below? There’s no assemblies in there because the assemblies never exist on the disk. It’s actually faster and easier to have the compiler do all the work in memory.

Migrating NHibernate 2.1.0.4000 to .Net Framework 4

I have a project which uses NHibernate.dll. We moved the project to use .Net Framework 4.0. We use FxCop and FxCop start failing and error appeared
Could not resolve assembly Nhibernate.dll so my guess was if i could move NHibernate.dll to move to .Net Framework 4.0 that would do the trick.
I tried and it gave like 100 errors about which ISet am i using is it System.** or Ies.Collections.Generic. I used Ies.Collection.Generic because Nhibernate has a reference to it.
I successfully managed to migrate it to .Net 4. but when I accessed my web application I got below message.
Inheritance security rules violated while overriding member: 'NHibernate.Cfg.Configuration.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Although I am not overriding anything at all. I searched on internet and found couple of article but I do not want to change NHibernate code Because that is not my code.
Why am I not using latest NHibernate?
because when I used this my project broke and the error was there is no overload method which uses 3 parameters (which my project uses) for
FilterDefinition(string name, string defaultCondition, IDictionary<string, IType> parameterTypes, bool useManyToOne);
Now they have 4th parameter which I am unsure what the results will be.
Question:
Could someone please help me with this error?
Has someone migrated NHibernate to .Net 4 successfully?
thanks
References:
http://forums.lhotka.net/forums/t/9914.aspx
Inheritance security rules violated while overriding member - SecurityRuleSet.Level2
http://community.codesmithtools.com/Template_Frameworks/f/67/p/12331/47618.aspx#47618
Weird override problem with Fluent NHibernate and .NET 4
I know this is not quite the answer you are looking for, but this is how I approached upgrading from:
asp.net 2.0, IIS6, NH 2.1, MVC2 project to:
asp.net 4.0, IIS7.5, NH3.3, MVC4
Make sure I have integration tests across most of the project (I won't lie this is what took a lot of my own time to achieve). Also use an error logging module like ELMAH
Upgrade to NH 3.3, run tests, push live and leave for a week to catch any bugs.issues
Upgrade to SLN .NET 4 (NO RECOMPLING OF NH IS NEEDED), run tests, push live and leave for a week to catch any bugs
Upgrade from MVC2 to MVC3, run tests and push live, leave for a week
Finally updgrade from MVC3 to MVC4
Personally I found this was the best approach and certainly gave me less pain points as I did not do too much at any one time. Also I could not have done this without integration tests covering probably around 70% of my code.
If I had gone straight to .net 4 and NH.3.3 then I would have been in a world of pain as there are always issues upgrading any project. My advice for what is is worth is to do it slowly.
Also the great think about having integration tests that an future code modifications or upgrades should be painless.
This below link helped me which oskar commented
https://github.com/oskarb/nhibernate-core/commit/d5f10c538440c127341159b31bff242ff9d687af

Categories

Resources