I have a current site written in classic ASP VB and I would like to upgrade it and I have been working heavily in ASP.NET MVC 3.
I would like to find a solution to get a system that works with both CLASSIC and ASP.NET.
Is there a way to develop a new system in MVC and navigate in and out of CLASSIC and back into MVC workflow?
If so, whats the best way to achieve this?
Your biggest issue is state. In ASP, chances are you threw a lot of crap into the Session object. ASP.NET (MVC or web forms) and ASP do not share the same session (state), so you end up having to store state somewhere to have it continue to work.
As long as you can get a place to store the state that both ASP and ASP.NET MVC can both consult, you can start migrating the pages piecemeal. If you cannot figure that out, you will have to scrap the ASP after you completely rebuild the site in ASP.NET MVC.
NOTE: I have been leading migrations (ASP >> ASP.NET (both flavors) and VB >> VB.NET). Unless you absolutely have to use a mixed mode, you are better to rebuild and then migrate the site over rather than rely on a mixed site. The worst thing that can happen is somebody stored something stupid in session or application, that you did not envision, and you are now in a place where you are not keeping something important. And you probably find it after a user complains about some transaction they did that did not migrate and now you no longer have any information about it.
NOTE 2: Sometimes clients want to migrate piecemeal and refuse to listen to you stating it is a bad idea. Your option, at this time, is move on to another client (or job) or do it. If "do it" is the option, make sure you have your butt covered, as this is a minefield.
Based on my experience, the answer is no.
The problem between ASP and ASP.NET are that their Core are completely different. For example, there is no way to share their Session values because they work completely differently.
The only workaround I could see would be to put the shared information between the two technologies in the database for the other to consume, but that's dirty since that information is only temporary.
If you don't need the identification or any other information shared between the two other than persistent information, you can include an ASP file anywhere is a ASP.NET MVC solution. Visual Studio will try as hard as possible to give you IntelliSense (but it won't work between ASP and ASP.NET modules) and IIS should be able to execute the VB code in the ASP file. When you switch from a technology to another, you include a certain ID in the address.
If it's not your case, the best way at that point is either to keep the project as legacy in a ASP project which may work very well for many years if some standards are well implemented or to switch entirely the project to a ASP.NET project and start from scratch.
Related
I am looking for a way to use HTML, CSS, JS Framework like Angular or Vue in the front page and use C# without ASP.NET in the backend to develop Single Page Applications. Is there any possible way to do it? I mean can we use C# without ASP.NET in the backend as an API and develop Single Page APPS?
I googled it a lot but did not find any helpful resources so I came here to get help of the stackoverflow experience.
Thanks in advance for any help.
Yes, ASP.NET is an entirely optional part of a .NET web application.
Depending on how you want to host it, you can just let your code work in an Owin middleware, an IIS module or handler or a plain old HttpListener, and so on, causing "raw" HTTP requests to end up in your code.
You can then mix and match features from ASP.NET or third-party libraries such as routing, security, content negotiation (serialization), bundling and minification and effectively you'll be creating a Frankenstein monster that won't work as well as ASP.NET and that others can barely maintain.
At least one such framework already exists and is called "Nancy", and has all the drawbacks mentioned above, in addition to a barely maintained and poorly debuggable cousin of Razor.
So the answer is "yes, but why?".
We are currently considering moving from ASP.NET MVC to Angular 5, mostly because it seems like the best and latest framework. However none of us seems to be able to come up with hard reasons on why Angular is better than MVC (Razor).
SPA vs MPA seems like different approaches with neither really being better - just better at different things.
Are there any resources/comparisons with hard benefits between the two?
Update: Almost 2 years after moving to Angular 4 (currently 7) I can say that it was a great decision. Angular makes it super easy to write quite complex front-end applications and the tooling around Angular itself, TypeScript, Karma + Jasmine (unit test frameworks) is fantastic. SPA is a huge step ahead of MPA in my opinion - we can finally have fluid web experience. I never really liked Razor and the whole mess around ajax/jquery, but I can comfortably say that I am really enjoying my time now! .NET CORE 3 + Angular 7 gives us everything we need!
To anyone thinking of taking the plunge, I would strongly recommend Angular (might as well start with 8 or 9, which is current at the time of writing this).
Happy to add more details if people want them :)
6 months on from moving from ASP.NET MVC to Angular 5 (now 6) and we are extremely happy with the decision. .NET core backend and Angular frontend is a fantastic combination. It is so much cleaner and easier to create re-usable, strongly-typed, testable and easy to modify UI components!
For anyone considering if it's worth taking the plunge - I would say a resounding 'yes'!
I don't have enough points to make a comment but thought the following might help you in making a decision.
Just to note that if you use Angular CLI (The default Angular project in Visual Studio) you will lose the ability to use razor within the HTML. Something you was able to do before Angular CLI.
I do like using Angular but miss having Razor to omit certain parts of the HTML, for example, if the user didn't have the necessary roles or permissions:
#if(User.IsInRole("Admin"))
{
}
You can hide the HTML using Angular of course, but having it completely removed from the HTML itself is preferable in my opinion.
I vote for an ASP.Net MVC Web Application in the cloud [Core or whichever] , and use of razor pages as needed. That is it. Case closed.
Even if the whole world runs after Angular , Aurelia, React, Node, Strawberry, Pistachio, butterscotch JS, I will not.
After all, JavaScript is spagetti and Angular is the Flying Spagetti Monster
based on personal experience and intuitive take.
Now please don't get started about mouse hover over page areas,
What I did found out about Angular vs MVC (Razor), I can work with both :-)
Authorization: One thing to make sure is that you don't have complex authorization schemes. On the backend its easy to do your authorization on pages with Razor (even more with Core). Its more difficult to handle authorization with Angular because you will have to do it (and keep in sync) on both sides: client and server. Example: One thing you want is hide everything a user is not allowed to do. If you have a simple webapp and use a Masterpage: show only the menu items a user is allowed to see. Thats a very easy task to do in Razor. It takes more time/effort to implement this in Angular.
Templates: Razor is extremely easy to use with templates. If you develop a website that must be used a number of times but with different layouts that can be done very easily with Razor.
Maintenance: With MVC you have one application. The frontend and backend are one. For maintenance you will have a Angular frontend and X Backend, so two. That seems more costly from installation, maintenance, etc. point. If you have a simple application I would say KISS: Keep It Simple Suckers.
One: In MVC the frontend and backend belong together. That can be good or bad. If you have one application with no dependencies on other things I think MVC is a good choice.
Future proof: Angular is NO W3C and NOT baked in the browser. Because of Future proof solutions there is a strong interest in Vanilla Javascript together with Web Components. With MVC you can use this technology. Read about Microsoft FAST Design. It works great with MVC.
SPA/MPA: Thats not a point anymore. An MPA can also be flicker-free with libraries like PJAX etc.
Speed: With MVC no wait time because Shit has to be loaded. Enough bad Angular websites already exists because loading takes ages.
...: After working with Angular 9 I don't get the point of Angular. I don't know why you should go from MVC to Angular. Visual Studio has great support for MVC and is much better as VS Code. From productivity point I can produce much faster code with MVC as with Angular. If you have multiple front ends that must connect to the same backend may be then I can see the point. But even then MVC can be moduled and even can dynamically load them.
htmx Wow, now we are talking! Yes this is what we want. Let Html take back control how pages are loaded. Think this is the way to go. Worked a sample with NodeJS and are very exited about it.
Update: I just did a nodejs/express/mongodb project and it beats it all. I am an expert mvc developer, but developing faster, better on a chromebook of 220e with vs code. now I know why it's so popular. and guess what? it's free. and guess what else? part of dotnet Core is based on nodejs. the console app is the same as a nodejs server. both you will have to put behind a proxy of IIS, Apache or NGINX.
One thing that I learnt during the comparison of MVC and Angular, among various factors, is that hosting MVC application requires a compute power container like Azure Web App, docker etc, while an Angular App can be deployed in any storage like Blob, CDN etc. When Angular is built, it gives a collection of javascript files, which are perfect candidate for storage container. They do not need compute power at all, which are the most costly resource in cloud world. CDN or Blob exposes Rest API endpoint to any of its underlying resource. So, the Angular will also be exposed as an API, which is all we want.
However, angular alone will not generate dynamic web pages. We need Web-Api at back-end to give the data. This can be achieved by a server-less solution (Function Apps, Logic Apps etc) or by containerization (Docker).
One downside that I personally found that the first time load of the Page in Angular is bit slow. After that it is really smooth.
All in all, I will vote for Angular/React and .Net Core in my future Web projects.
I have recently started an internship in a big company (4.5k employees) which uses an Active Directory and have an intranet web app allowing them to handle all types of services, going from administration to user creation etc ... It was developped in 2004 and now they want to remake the whole application, well actually I have to make it. And kind of on my own, I am the only developer here.
I was thinking of developing an ASP.NET MVC 5 project to develop this application, do you think that is a good choice? Don't know many other design-patterns for this, and I found on the web that Active Directory is accessible using ASP.NET MVC, and everything seems compatible. The old project used a hand made architecture, which didn't respect any design-pattern and using mainly VBScript. I want to use C#, that's the only imperative I guess.
Thanks for your help, I hope this is clear, if not I will try to make it clearer :D
ASP .Net MVC seems to be a good choice. You can use ADAL for authentication and manage any kind of AD data. Here are some links:
Http://www.ianatkinson.net/computing/adcsharp.htm
But you must master ASP.Net MVC (Bootstrap / razor / ...)
Good luck !
Due to time issues we need to be able to add new button click functionality to an old .net site whilst coding the back end in MVC5 as the rewrite is going to be MVC5 but rewriting the entire page at the moment is too much work. So I want to be able to call the MVC 5 app from the .net 2 app requesting an object and that be returned. I have begun investigating Cross Domain Requests, but unfortunately the microsoft example doesn't work, I think they may have moved some pages around. Could someone point me in the direction of good documentation/Examples or another (maybe better) way of achieving this.
Thanks in advance
I have an application that I want to (eventually) convert to ASP.NET MVC. I want to do an all out service upgrade (to ASP.NET) but want to use current asp stuff to run the current functionality so I can upgrade small pieces while making incremental upgrades to the new framework. This site is heavily dependent on a VB6 DLL that is not very mature, so we will also want to upgrade this eventually too, potentially replacing the current functionality with web services. Is there a quick fix or is this task a 3 month + task? Also, I am sure it has been thought of before, the beauty of the MVC is that I would think there is a way to tackle this, though I am unsure of where to start. What would be the quickest way to convert this application (in 40 or so hours), where I can just make small configuration changes and have this working in ASP.NET MVC?
The short answer is... You can't. The differences between classic asp and asp.net are fairly drastic not just in syntax but in overall design. MVC is not just a similar implementation to classic asp although it may look that way. Any conversion will take time, thought and effort to get it completely working.
The good news though, is that you can run them SxS so you can actually have classic asp code running under a site that is setup as an ASP.NET or ASP.NET MVC site. So with some duct tape you can peice together your upgraded solution part by part.
Rewrite your VB6 DLL as a COM callable .NET assembly. Then, you can reference it both from ASP and ASP.NET.
Hopefully, most of the heavy lifting is in the VB6 DLLs. If so, you can then start migrating pages over to ASP.NET MVC as you want. You have to watch out for page-to-page communication - things like Session and Cookies. Cookies will pretty much work as is, but you'll need to move Session to something shareable between MVC and ASP like Sql Server. Unfortunately, that requires rewriting your Session calls in ASP to something else (possibly a COM wrapper around a .NET component again). Search and replace should do the trick, though.
As for the timeline and amount of work this entails - that's pretty context dependent on the amount of spaghetti in your existing app, how much logic is in the DLL vs. ASP, and how many pages you're migrating.
I don't think 40 hours is a reasonable amount of time to get up to speed with .NET, MVC, and rewrite - though I think 2-3 months could be.
I have been working on a similar project for quite some time now; We had a classic ASP app and wanted to move it to ASP.Net (using WebForms). We do it a piece at a time, if we are adding a new page we do it in .Net and just redirect the user between the .asp files and .aspx files. Working with MVC should be no different.
The biggest issue we ran into was security; The site required a log in and the session is of course not shared between the two. We handled this by persisting the bits of session we cared about to a table in a database and passing a GUID through the query string (we only do this one time at login, then delete the record from the database to reduce security risks).