Classic ASP and ASP.NET MVC2 Integration - asp.net

I have inherited a Classic ASP application with a Delphi COM layer. I am tasked with migrating the app to ASP.NET MVC2 and C# with web services replacing the Delphi. Due to the amount of users of the application and the fact that I'm the third developer this company has hired to do this, the company would like to migrate sections at a time. That leaves us with a mixed hybrid of Classic ASP and ASP.NET MVC2 sections. My guys and I have built the first section of the app and are ready for integrating the apples and oranges. My question is, has anyone done this? If so, how? The first attempt is creating a sub-folder in the classic app and inserting the MVC stuff into there. Doing it this way, I cannot get any urls to work. It's probably some ignorance in the MVC pathing but if anyone has any tips at all on this, combining ASP and MVC2 I would love some help.
Thanks and I apologize if this is a bit vague, I'd really just like to start a conversation or connect with someone that's done this before.

First, you need to make the subfolder in the classic app a Virtual Directory or Wep Application for MVC to work, it wont work simply dropped in a subfolder of an IIS website.
Second, if the app is authenticated, you need to figure out a way to share the authuthentication so users don't have to login every time they switch sections of the app. (Unless thats an acceptable situation, which I doubt). Sharing this authentication may involve making some changes to the existing application, or possibly not.
I wonder what is the scope of this project and why it cannot be done in one felswoop? I'm not saying doing it in phases is bad, but if that is a requirement, you'll need to address the above issues.

I think that much better way is rewrite app to MVC from scratch. No step-by-step, no mixing. It will save you a lot of pain and also it will take much less time to do, even it doesn't seem so at first sight.

Related

Mix c# and vb.net webforms in single project

I want to reuse a project developed in vb.net in c# webform project. The login form should be same for both the projects. How can I achieve this? Can I add vb.net and C# forms in single project.
If created as separate projects in single solution, can I share the session variable between two projects?
I want a common login form for c# and vb.net project. Need to share user credentials between two apps
Well, you can intermix pages of vb and c# only if the web site is NOT a web site application.
So, it kind of depends.
If your web site is setup as a website application? Then no, you can't do this.
You can certainly take any of the code modules, classes, and business logic from the vb.net applcation, and refreence such assemblies in the new c# project.
And its not really recommended to do this anyway (ie: mix both types of pages in one project - but, you can do this for a web site, but not for web site applications).
I see VERY but VERY little advantage to simple re-writing all that code. It not like your going to get more features, or anything of value here.
If you looking to migrate to .net core, MVC etc? Then again, those pages could not be used anyway - even if they were written in C#.
So, either you consider this a migration project out of webforms (and .net 4.8), or you don't. Anything in-between is really a waste of time and resouces. If that site is to continue running as webforms, then I can't really make the case to migrate the code to c# - I just don't see any benefits here.
So, this can work for a asp.net web site, but not for a asp.net website "application".
And, I always hands down preferred the "application" choice, since then things like including other projects and code (often written in c#) can be used and is supported.
But, a page with code behind in vb.net, mixed in with pages and code behind in c#? No, you can't do this with a web site application, and giving up the application choice (vs that of a web site) I think is too high of a price to pay in that you lose out of the benefits of a asp.net application choice in the first place.
This sounds like good money after bad. Unless you going to migrate to a newer framework? It makes VERY little sense to spend time + money to migrate to JUST c#, and I can't see any real benefits of doing so.
if the developers in question know well asp.net + webforms, then the learning curve to maintain the site "as is" with vb.net? I can't see more then a day or so for any good c# developer to get up to speed with vb.net.
c# or vb.net is really moot - what matters is a good solid skill set in the .net framework, and unless you jumping over to .net core, then as noted, I can't see how the cost of this work can be justified. it in effect amounts to stealing money from those paying for this conversion, and that means someone is being mislead, or miss informed here.

Best practise to migrate Web Forms to ASP.NET Core MVC

I am trying to migrate a project from classic ASP.Net Web Forms to ASP.NET MVC.
While I have read through http://www.codeproject.com/Articles/38778/ASP-NET-WebForms-and-ASP-NET-MVC-in-Harmony. I have a basic idea on how the code structure, libraries and routing should be done.
For your information, the scope of my existing project is around 400 pages and 300 tables.
On top of my head I have two approaches:
Start from stretch, rewriting the whole system - Obviously this would require intensive work and take a long time. Any change made on existing system would need a duplicate change made to the new system.
Migrate the page one each - I still have a rebuild the entire core library (for accessing db), and get the page migrated one by one. For this I would assume to have two core libraries (new and old) running simultaneously with different pages connect to one of those.
Would anyone have similar experience and advise a proper way to start?
For this complete revamp I may also target at the latest technology - .NET Core and MVC6, by taking these would I have extra advantage, or some blockages I would have to take care of?
Any suggestion and opinions are appreciated. Cheers.
Microsoft is a bit hush hush on the subject but the WebForms engine is probably never going to make its way to ASP.NET Core. One might think that MS is waiting to see if the community is calling for a port, but I think they're trying to kill it discretely (not like Silverlight).
Why? Because it proved to be a bad good idea on the long run, easy to use at first, but extremely complex to master (because of viewstate and page lifecycle), with a tendency to allow average developers to build very tedious application (in french we say steam factories). Also it was very poorly adapted to modern web development (Ajax, unit testing, IoC). They tried to fix it with a couple of tweaks, but the overall architecture is just not adapted to this kind of things. MVC is a treat in comparison!
To answer your question, it's not really possible to migrate WebForms to MVC, because those are quite different architectures, and of course the architecture is what an application sits on top on, so if you change it, you might as well rewrite it from scratch.
What can help you a lot is if your app is divided in tiers (business, data access, UI). If it's not the case, you could start by doing this, properly separating the UI project from the rest. Then you would just have to rewrite the ASP.NET project and not the rest.
There are some useful resources I'd like to share with the StackOverflow community just in case you are having troubles to decide what to do:
modernization of your existing Web Forms app
migration to MVC or Core
or whether to start a new project on Web Forms, MVC and Core.
Here you go:
https://www.telerik.com/blogs/review-of-telerik-toolsets-for-aspnet-web-forms-core
Modernizing ASP.NET Web Forms Applications by Tomáš Herceg (Microsoft MVP ) - https://tomasherceg.com/blog/post/modernizing-asp-net-web-forms-applications-part-1
Migrating Old ASP.NET Applications to .NET Core by Edi Wang (Microsoft MVP) - https://edi.wang/post/2018/10/31/migrating-old-aspnet-applications-to-net-core
Choose between ASP.NET and ASP.NET Core (Microsoft docs) - https://learn.microsoft.com/en-us/aspnet/core/fundamentals/choose-aspnet-framework?view=aspnetcore-3.1
Migrate from ASP.NET to ASP.NET Core (Microsoft docs) - https://learn.microsoft.com/en-us/aspnet/core/migration/proper-to-2x/?view=aspnetcore-3.1
i have come across below links
https://www.youtube.com/watch?v=CZuqMrWSano
https://www.dotvvm.com/blog/59/Modernizing-ASP-NET-Web-Forms-applications-with-DotVVM
DotVVM package helps us to migrate ASP.Net Web Forms migration to ASP.NET Core without re-writting completely.
i have not tried any production application. still have tried some sample pages. you can try this out.
I can agree that for many cases a re-write of an ASP.NET application where WebForms is used widely may do not provide any business value.
Therefore we decided to use our experience with ASP NET WebForms to develop a highly compatible port of WebForms for ASP NET Core / .NET 6.0.
We use the solution in our own ASP NET WebForms-based products and projects as well as a licensable component library.
So the Forms can still be used and you can focus on the .NET CORE/6 migration.

ASP.NET MVC Experiences/Success Stories [2010]

At the moment we're evaluating whether it's worth it to start using ASP.NET MVC in combination with Visual Studio 2010.
I've been searching the web for experiences developers have had with working with ASP.NET MVC. I can't seem to find any. So I decided to post a question here.
Are there any people out there that have used ASP.NET-MVC for serious development? What are the experiences so far? Does ASP.NET-MVC help or hinder projects? Do you deliver your project on time? Does ASP.NET-MVC save you time or does it make you go over time and over budget?
And then the big question: Now that you've been working with ASP.NET MVC for a while, do you wish you had chosen an alternative? If that's the case, which alternative?
Thanks,
M
StackOverflow itself is an ASP.NET MVC site and I would say it is pretty successful.
I think it depends more on the people doing the actual implementation of the site than on the technology used how 'successful' the end result will be (successful in the broadest sense: on time, within budget, happy end users, ...).
Asp.net mvc is a better then asp.net webform some reason are here
the logic code in asp.net MVC is maintainable and clean.
he provide a better performance then webform
provide a pretty url for SEO and user-friendly.
full control on mockup [without using server-side control].
if you want to see there are many example of MVC project. stackoverflow.com is one of them.
I am a big fan of ASP.NET MVC (especially with the great improvements done in MVC3). I have worked on two big sites built entirely in MVC2 SempToshiba Brazil and Cyrela Brasil. These projects have been quite sucessful. They were delivered on time, saved time and our clients were very happy. Lastly, no, I would not have chosen an alternative. A side note, the Cyrela project was actually a re-do of a ASP.NET Web Forms site that had various downsides.
On the other hand, I have seen a large project done in MVC 2 by inexperience programmers, and it is one the worse projects I have ever seen. So, over all, ASP.NET MVC has some major advantages, but if the team is inexperienced in ASP.NET MVC you will get poor results.
On another note, this post has some great ASP.NET MVC 3 material.

Using ASP on ASP.Net site

I have a client that currently has a shopping cart written in ASP that he wants to keep using. We are looking at upgrading the rest of the site to DotNetNuke which is based on ASP.Net.
Does anyone have any guidance on how to use asp pages in an asp.net application? IFrames? I did a little ASP just before dotnet came out, so I"m not that familiar with ASP.
You can combine them pretty easily, you will just need to have the asp have its own global.asa and session timing. As long as your authentication logic is simple, you can write it in both, or consume it as a service from the asp pages.
The main concerns are shared state amongst pages. IFrames are viable options, but hard to get to look natural.
I'm currently doing this in an application that is half converted, its 170 aspx pages, and 210 asp pages.
That said, the context switching of maintaining both parts, is painful. So try and get it rewritten, quickly. On MVC its fairly trivial to have the logic flow like asp.
You can mix the two, but I don't think you'll be able to do things like share state between them unless you cater for this with a third party provider. They'll behave more like two "seperate" sites.
One other thing worth mentioning is that if you are provisioning a new web server for the mix, and planning to pull in the old ASP code, is that ASP is not enabled default on the more recent versions of IIS.
You can't use ASP pages in an ASP.NET application.
You can have an ASP application and an ASP.NET application in the same web site, but they are still two different applications. They work side by side, basically unaware of each other.
You can have the pages communicating with each other, and even use iframes to seamingly mix them in the same page, but communication is not trivial as the web applications can't communicate directly. You can communicate between them on the client side, or through a common backend database (or any other indirect way that you can think of...).
You would be much better off using a single ASP.NET solution.
There is a DNN shopping cart module available from here. There is supposed to be a community edition. [I haven't used it, so can't say how good it is]
Most asp is going to valid as asp.net. You may be able to rename your .asp pages to .aspx and get 80-90% of the old code working under asp.net. Then fix anything that's broken and slowly migrate more and more of the old code to proper asp.net.

Can "classic" ASP.NET pages and Microsoft MVC coexist in the same web application?

I'm thinking about trying out MVC later today for a new app we're starting up, but I'm curious if it's an all or nothing thing or if I can still party like it's 2006 with viewstate and other crutches at the same time...
Yes you can have your webforms pages and MVC views mixed in a single web application project. This could be useful if you have an application that is already built and you want to migrate your app from webforms to mvc.
You need to make sure that none of your webforms pages go in the 'Views' directory in a standard ASP.NET MVC application though. Pages (or views) in the 'Views' directory can't be requested directly through the url.
If you are starting an application from scratch, there would be very little benefit to mixing the two.
Yes. MVC is just a different implementation of the IHttpHandler interface so both classic ASP.NET and ASP.NET MVC pages can coexist in the same app.
As you've probably noticed with the above answers, yes this is very possible to do.
I've actually had to do this on my current project. I was able to get approval to add MVC to our application, but only in the administration section (to limit the risk of affecting current members coming to our site).
The biggest problem I had was converting my Web Site to a Web Application, but once that was done, things were pretty straight forward adding MVC side-by-side our classic code-behind web pages.
The trick for me was to make my MVC pages look as similar as possible to my code-behind pages so the transition looked as seamless as possible.
I am currently working on a new project. While I would like to go down the MVC route all the way, some of the project requirements don't allow me.
One of those requirements is to have a grouping grid from the client-side. Personally have chosen the Telerik Rad-Grid. While they may be in the process of supporting MVC they are not there as yet.
So this means that I have to have a hybrid solution. for the time being until RadGrid fully supports MVC.
While we are in this transition period I think that there will be may more hybrid projects out there until the support of the Third Party Controls catches up.
Regards
Nathan
You'll need to make sure your MVC routes don't conflict with your Web Forms pages so that requests for a .aspx page don't get routed to a controller action as a parameter etc.
See this blog post by Phil Haack for details on how to avoid this.
Yes, it is very much possible for MVC pages to coexist with asp.net web forms. I implemented that in my existing asp.net application for adding new features. We need to make sure of referring the MVC DLLs, registering routing tables for URL routing and configuring the assemblies and namespaces in Web.config file.
If you're mixing MVC with other methodologies you're not really getting the benefit out of it. The point of MVC is to allow you to decrease coupling and increase cohesion, and if only half of your code is doing that, then the other half is inevitably going to restrain your development cycle.
So, I guess while it's possible, I don't think it's worth it. Go all the way or don't go at all.

Resources