Migrating from ASP.NET WebForms to MVC [closed] - c#

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I've read plenty of questions and articles stating that converting from ASP.NET Webforms to MVC is near enough impossible. However I think my scenario is different.
I foolishly started working a project about a year ago in Webforms, but the approach I took (as far as I understand) is very MVC like. I have disabled forms validation, don't use any postbacks, use URL re-writing and all page changes are AJAX requests that load the page contents of ContentPlaceHolders (using a small hack, overriding the RenderControl method). I've also used my own ORM and RESTful Service API in seperate projects, referenced in the website.
Now the system works really well, the pages are partially refreshed fine and the url's are changed when the ajax calls are made, so when the page is refreshed, it looks exactly the same.
Now I've just been told I need to learn MVC for a new big project (but I have to finish another project first), but I've done a bit of reading on the subject and started a few Hello World apps, and it seems that the idea of ASP.NET MVC is pretty much exactly what I have already created.
Would StackOverflow still recommend against converting the Webforms application to MVC? Are there any other benefits of converting to MVC, besides best practices?

I have a very large and old ASP.NET WebForms application (which was originally written for .NET 1.1!) and have enabled MVC to work in it, side-by-side. I've been writing new features using MVC, and converting old WebForms features to MVC controllers and views.
I ran into a few little issues concerning URL authorization and running in IIS integrated mode, but once I understood the issues they were fairly easy to work out. So nearly impossible? Certainly not!
I can't tell you if it's worth your time to convert it, since I don't know the size, scope or nature of your application, or any business constraints. However, moving to MVC has been a considerable boon to ease of development and quality (since it is easier to compartmentalize and unit test). Not to mention, the features I've written (or rewritten) in MVC are much cleaner, faster, and responsive than the WebForms equivalents.
I'm excited to move it from MVC v2 to v3, and convert to Razor views. So would I? I if I were you and I had the time, I'd do it.
Here's a question I posted that outlines the process and one of the more significant problems I had in the conversion. Migrating legacy ASP.NET to MVC 2 (RC): HttpApplication events not firing, User principal is null

I've recently converted a medium size project from WebForms to MVC. I would not recommend doing that on your first MVC project, but once you get the hang of it there really is nothing stopping you from (gradually) converting a WebForms app to MVC.
One of the major benefits I've noticed is speed. By throwing out the viewstate, databinding and web control weirdness you'll end up with a much faster application.
Of course there's also the better known benefits like testability and full control over the generated html.
WebForms and MVC share the same basic ASP.NET platform, so they are really not as incompatible as you've read.

Related

C# MVC vs ASP.NET MVC difference? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am an intermediate C# developer and taught myself the basics of C# MVC, but not ASP.NET MVC. I already know classic ASP and ASP.NET though I haven't used them in many years, at least 5, since I mostly do C# desktop development at my job. The thing is, I now want to migrate all of our existing C# applications to the web..
So, I am going to start looking to hire a new developer but my question is this, since I don't really know ASP.NET MVC specifically would it be smart to look for a C# MVC developer only, since I plan to have all our internal C# apps migrated to the web? I know that ASP.NET and C#.NET can be used together but I want to try and keep everything uniform. This person will likely have to understand some C# to be able to migrate our internal apps so should I continue looking for a C# MVC developer only or do you think an ASP.NET developer will have no problem? I imagine there are plenty of ASP.NET MVC developers out there but not as many knowledgable with C#...plus it would help if they understand the not-so-difficult C# written apps when they they migrate to MVC.
Can someone explain the pros/cons or differences between the ASP.NET MVC & C# MVC or what issues I should expect to come across?
Thanks in advance!
Well, there is no C# MVC.
MVC (Model, View, Controller) is an Architect Pattern.
ASP.NET MVC is an implementation of this pattern of Microsoft ASP.NET and you can use C#, VB.Net and other languages to programming on this platform.
You also can build your application using MVC principles (for sample) in a Windows Forms application without any default implementation like ASP.NET MVC.
In general, I try to test for general programming and problem-solving skills.
If a developer cannot quickly pick up a new library or language, I probably don't want to commit to hiring them.

ASP.NET learning path [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to ask experienced ASP.NET developers about how to climb the learning curve of ASP.NET.
I am an experienced C++ and C# developers with no web application experience.
I found ASP.NET MVC and ASP.NET are two different technologies. I just want to ask:
Whether these two technologies will co-exists or MVC will replace
ASP.NET?
If I want to learn ASP.NET MVC. Do I need to learn ASP.NET as a prerequisite?
Can you recommend some learning resources? Book? Video? Not paid Microsoft training :(
Many thanks
First of all ASP.NET is request/response pipeline. This means that you are given access to the request and response streams as well as some provisions like, session, cache, security, etc.
On top of this there are 3 frameworks in charge for generating HTML. The first and oldest is known as ASP.NET Web Forms. Because it was the only one it is sometimes called ASP.NET but this is not correct in the current state of things. ASP.NET MVC is the second one and there is a third one known as ASP.NET Web Pages. All 3 of these share the same core ASP.NET request/response pipeline and the APIs for Session, Cache... What is different is how they generate HTML.
You can check my answer to this question for more info.
Asp.Net Web Forms and Asp.Net Web Pages
And to answer your concrete question - no Web Forms is not going away. A lot of people use it, MS are releasing new versions.
Web Forms is pretty good for people with desktop background because it uses a control model familiar to desktop devs and also has something that simulates state. It also requires less knowledge of HTML, JS, CSS. ASP.NET MVC is kind of the opposite. It gives you a lot of control but requires a lot of knowledge about the web.
I personally prefer Web Forms to MVC for a variety of reasons that I will not list here but even Web Forms supporters (and especially me) will admit that Web Forms is pretty bad way to learn about the web because it abstracts a lot of things. This gives you productivity, security, etc. but can result in cases of leaky abstraction if you don't know how the underlying framework works and it is pretty easy to skip learning the details because you know stuff just works... until it breaks and then you don't know where to start.
Ultimately the choice is yours but if you start with Web Forms be sure to learn about HTTP verbs, cookies, raw response stream, http headers, html form/submit model inline css vs separate files and javascript out of the context of Web Forms and make sure you know how Web Forms automates these.
1) Whether these two technologies will co-exists or MVC will replace ASP.NET?
The official position of Microsoft today is that those two technologies will coexist. ASP.NET MVC will not replace classic ASP.NET. At least Microsoft will continue shipping new features in ASP.NET.
2) If I want to learn ASP.NET MVC. Do I need to learn ASP.NET as a prerequisite?
Not necessarily but it will be better if you learned it because as ASP.NET MVC is based on ASP.NET kernel and it will help you be a better understand the underlying technology.
3) Can you recommend some learning resources? Book? Video? Not paid Microsoft training :(
http://asp.net/mvc is a good start.
Can't say if one is going to rule the other one out.
But the easiest to learn is asp.net MVC.
Pro ASP.NET MVC 3 Framework
this is a good book to learn it.
http://www.w3schools.com/aspnet/default.asp
http://aspauthors.com/aspnetbyexample/
http://www.exforsys.com/tutorials/asp.net.html
Some links which may useful to you.
Darin gives you good answers on 1 and 3, but i disagree some on 2:
2) If I want to learn ASP.NET MVC. Do I need to learn ASP.NET as a prerequisite?
No. ASP.NET WebForms (often reffered to as just ASP.NET) has a VERY different paradigm.
While ASP.NET WebForms tries it best to hide all the web (like POST vs. GET, the HTML, how to maintain state) stuff from you, ASP.NET MVC is dependant on knowing and understanding the same things. Learning aboutWebForms' ServerControls and ViewState are of little help.
There are of course parts of the ASP.NET stack that you'll encounter in both WebForms and MVC. The different state mechanisms (session, application, cookies etc.), the Server, Reguest and Response objects, caching mechanisms, jQuery etc. are used in both places.

Why is ASP.NET MVC more maintainable then Webforms [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
MVC versus WebForms
Almost all asp.net mvc vs webforms post I see on SO the selected answer always say ASP.NET mvc is more maintanable but do not give any reasons why. Do you know why MVC is more maintainable then webforms?
A lot of the argument for ASP.NET MVC being more maintainable than WebForms has to do with the following:
It cleanly maps to how web requests actually work, instead of shoehorning an eventing model onto the web.
There are more extensibility points to provide flexibility in solving problems.
The MVC pattern in general just tends to be more maintainable than a number of things due to the separation of concerns.
This is not to say however that WebForms cannot be written to be maintainable. There are definitely cleanly written WebForms applications out there, just as there are many cleanly written ASP.NET MVC applications.
Of course, you can make web form application maintainable by, for example, using MVP pattern. But most programmers doesn't do that because putting logics all over webform is quick and easy choice. After that programmer got fired or quits, next programmer should follow all the logics to fix a bug in the system. But that creates another bug because test can't be implemented. If the system is complex enough, any change almost guarantees a bug.
MVC doesn't give you that choice for easy path to hell. But this design pattern stuff of ASP.NET MVC is just small part of the story. You can google for the whole story.

Razor/CSHTML - Any Benefit over what we have? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Anyone out there using the new CSHTML pages feature and is finding that they prefer this new view engine syntax over the existing ASP.NET MVC default view engine or over web forms, and if so, why? What about CSHTML gives you an advantage over MVC or web forms, or vice versa?
Just curious to hear people's take on it.
One of the benefits is that Razor views can be rendered inside unit tests, this is something that was not easily possible with the previous ASP.Net renderer.
From ScottGu's announcement this is listed as one of the design goals:
Unit Testable: The new view engine implementation will support the ability to unit test views (without requiring a controller or web-server, and can be hosted in any unit test project – no special app-domain required).
Ex Microsoft Developer's Opinion
I worked on a core team for the MSDN website. Now, I use c# razor for ecommerce sites with my programming team and we focus heavy on jQuery front end with back end c# razor pages and LINQ-Entity memory database so the pages are 1-2 millisecond response times even on nested for loops with queries and no page caching. We don't use MVC, just plain ASP.NET with razor pages being mapped with URL Rewrite module for IIS 7, no ASPX pages or ViewState or server-side event programming at all. It doesn't have the extra (unnecessary) layers MVC puts in code constructs for the regex challenged. Less is more for us. Its all lean and mean but I give props to MVC for its testability but that's all.
Razor pages have no event life cycle like ASPX pages. Its just rendering as one requested page. C# is such a great language and Razor gets out of its way nicely to let it do its job. The anonymous typing with generics and linq make life so easy with c# and razor pages. Using Razor pages will help you think and code lighter.
One of the drawback of Razor and MVC is there is no ViewState-like persistence. I needed to implement a solution for that so I ended up writing a jQuery plugin for that here -> http://www.jasonsebring.com/dumbFormState which is an HTML 5 offline storage supported plugin for form state that is working in all major browsers now. It is just for form state currently but you can use window.sessionStorage or window.localStorage very simply to store any kind of state across postbacks or even page requests, I just bothered to make it autosave and namespace it based on URL and form index so you don't have to think about it.
Everything is encoded by default!!! This is pretty huge.
Declarative helpers can be compiled so you don't need to do anything special to share them. I think they will replace .ascx controls to some extent. You have to jump through some hoops to use an .ascx control in another project.
You can make a section required which is nice.
The biggest benefit is that the code is more succinct. The VS editor will also have the IntelliSense support that some of the other view engines don't have.
Declarative HTML Helpers also look pretty cool as doing HTML helpers within C# code reminds me of custom controls in ASP.NET. I think they took a page from partials but with the inline code.
So some definite benefits over the asp.net view engine.
With contrast to a view engine like spark though:
Spark is still more succinct, you can keep the if's and loops within a html tag itself. The markup still just feels more natural to me.
You can code partials exactly how you would do a declarative helper, you'd just pass along the variables to the partial and you have the same thing. This has been around with spark for quite awhile.

Resources for learning ASP.NET MVC 2.0 [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What are some good resources for learning ASP.NET MVC 2.0 (if I don't already know ASP.NET MVC 1.0)?
Tekpub (Steven Sanderson and Rob Conery) is doing a video series on MVC 2: http://tekpub.com/preview/aspmvc
Obviously the first resource I'd point you to is the official ASP MVC website here.
Perhaps the biggest and most key aspect you need to understand about ASP.NET MVC is that MVC isn't explicitly specialised for ASP.NET - it's a very wide design pattern - MVC stands for Model-View-Controller, you should really read up on MVC and gain a general understanding before you dive straight into the ASP.NET implementation.
You may want to look into buying a book that can nicely ease you into ASP.NET MVC. The reviews on amazon are something you want to take into account, as they're usually very accurate.
You can find results of a ASP.NET MVC search here.
As far as your concerns around version 1 to version 2 of ASP.NET MVC go, you shouldn't automatically dismiss any ASP.NET MVC v1 resources you come across - the chances are it's still relevant. You may wish to check out the changelist between v1 and v2 to see if anything you learn is now redundant, updated or changed in any way.
There is going to be a lot of help around for MVC 1. If you're looking to learn .NET MVC then most of .NET MVC 1 is relevant. Phil Haack is one of many who has blogged about the blogged about the release of .NET MVC 2. Importantly, he gives a link to the release notes.
Not a great deal has actually changed. Mainly to do with validation in fact. You can use the release notes as a guide. Whenever you're doing something that is 'flagged' in the release notes, then make sure you look for .NET MVC2 help specifically.
Brad Wilson has some nice posts about templates.

Categories