Should I build my next web app in ASP.NET MVC? - asp.net

My team is considering building our next web app using the ASP.NET MVC framework. I am slightly hesitant, as are some others, because it is still only in beta. I really want to dive in because it seems to be a great way of providing clear separation of concerns and improving testability.
Should I take the plunge now, while MVC is still in beta, or hold off for a release candidate?
From some of the responses, I think I need to clarify my question a bit. My primary concern is whether to go with a product that's still in beta, not webforms vs. mvc. The concern is mainly because of the fear that we end up using some functionality in the beta version that gets changed / deprecated / not supported in the final release.
However, I do appreciate the perspective on webforms vs. mvc. It just doesn't get at the heart of my question.

It's a pretty simple decision tree, really.
Choose ASP.NET MVC if you...
Care deeply about URLs
Care deeply about your HTML
Want true separation of concerns
Want testability through and through
Want flexibility of view engines (ASPX, NVelocity, NHaml, etc)
Choose WebForms if you...
Enjoy the stateful abstraction of WebForms (ViewState)
Don't mind PostBack model
Prefer components that you can "drag & drop" on a page
For me, the answer will 99% be ASP.NET MVC, because I think it is a much better match for the web. I think the ajax story is much cleaner as well, and I have complete control over my HTML & URLs. On top of all of that, I can test-drive my website (controllers) quite easily.
Yes, I know you can achieve clean URLs in WebForms, and you can have clean(er) HTML through Control Adapters, and you can achieve a level of testability with the MVP pattern in WebForms, but these are all off-the-beaten path approaches. With ASP.NET MVC this stuff is core. That's just the way you do it.
And don't worry about the preview/beta status. The team has always maintained that you don't need a go-live license to deploy it (even though they now offer one). It's purely additive on the existing ASP.NET Runtime.
It's like automatic vs. manual transmission. Pick one that makes you happy and run with it.

I prefer ASP.NET MVC to WebForms, so I would choose that, but you need to work out as a team where your core skill set is and whether or not choosing MVC will:
Create a better product.
Get you to market quicker.
Don't just choose it because it's new. WebForms is still a great choice, and you can write code for WebForms that's both testable and has clear seperation of concerns.

So far Mvc looks good, however I m a castle advocate I have used monorail in many production sites and it got me into learning about IoC and AR
Cheack out castleproject.org

I'd recommend giving it a shot.
We just recently released an e-commerce platform with MVC running the front end, and while there are some gotchas that you may stumble upon (Say, resolving Url's with anonymous types is currently far slower than using a RouteValueDictionary, was a surprise to me), it certainly feels like it was a lot easier to build a manageable system in MVC compared to our older WebForms apps.
If you have the luxury of choosing, then you should definitely have a closer look. The bugs that have shown up while we worked on it have all been fixed fairly promptly, and most things work well now, and it's starting to feel pretty complete.
But in the end, it's always a risk to take on an early beta product. :)

Unless your app is super simple, it's likely that MVC will be released before you go to production. That hardly matters though. I have been building on MVC since Preview 2. Each new version has contained breaking changes; however, they have not been very hard to track down and fix. It's very unlikely that by 1.0 you could create a mountain of code that would be toppled over by some breaking changes. Simply budget a few person hours to apply each new version.

If you don't have to put your app in production soon, yes write it in MVC.
Here, we have a team working with MVC and planning to put it on prodution at jan/2009.

If it's not mission critical and you and your team have the time to learn it, why not?

Related

Learning Web Development starting with ASP.NET MVC

I have been working with C# for past four years at the enterprise level. Now, I have taken a decision of moving to Web side of the things. Since I am well versed with C# and WCF I naturally zeroed in on ASP.NET as I need not learn a new Programming language. Learning just the Web Framework will suffice.
I have read a lot regarding MVC, so starting out with MVC 2.
My Question is Will I face any roadblocks if I learn MVC without learning Web Forms? Keeping in mind that this is my first foray into Web Development?
Looking forward to some good suggestions.
I was in your exact same position. The only problems you may have is wrapping your head around postbacks and what tha means. Having said that, MVC2 will teach you how to write better code instead of the typical spaghetti that comes asociated with webforms.
If you're new to MVC2 I'd recommend buying Wrox Professional ASP.NET MVC2 from writer Scott Hanselman.
Learning web development these days is hard as you need to be an expert on so many different things!
You need to learn HTML/CSS/JavaScript(ie, JQuery)/Json regardless of the server side framework you are using if you are creating “rich” web applications.
I would say starting with ASP.NET MVC is not a bad option before moving onto ASP.NET Web Forms. You are likely to hit both going forward, but as ASP.NET MVC does not hide what’s going on so much, I think it may be a better start.
However if you just wish to create simple forms on the web, it is hard to beat ASP.NET Web Forms, but as soon as you wish to do something more advanced, the Web Forms complex page cycle will give you pain.
If you're looking to apply your web skills to enterprise environments, you'd probably find a lot of environments still leveraging Web Forms. Outside of that, I can't imagine it would really hurt you that much.
The bigger thing about web development is getting familiar with HTML/CSS/JavaScript(ie, JQuery). The skills learned there are applicable to either environment. You'd probably be able so switch back end frameworks rather painlessly as long as you're used to c# and all the web stuff previously mentioned.
I think it depends on what type of applications you are going to be developing. I believe web forms would be easier for you to learn with the background you already have in WCF. But it might not be worth it if the applications you are developing are better suited for MVC rather than web forms.
My recommendation would be to determine what type of applications you are going to be developing and then look at the strengths and weakness's of each and then determine which one you are going to focus on.
You most probably won't. There are some concepts that belong to the web-application environment (session, caching, etc) that are common but you'd have to learn about them anyway. They are two separate frameworks so nothing very specific about one of them could help you with the other.
You will undoubtedly run into issues when knowing a "new" way of doing things without having been brought up in the "old" way of doing things. It's unavoidable, really. I'd suggest learning the basics of WebForms code if possible, if for no other reason than to be able to trudge through it when necessary. Of course, if you find yourself in the position of having to support a WebForms application, you'll learn by doing just like anything else.
This question reminds me of my early days in .NET (which were the very early days of .NET in general) and trying to find assistance with various issues. I was an entry level developer, hitting up forums and such with questions. Everywhere I went, people weren't really adopting .NET just yet. They were all old Windows platform developers, whereas .NET was my first Windows development (I was all UNIX/Linux in school). Invariably, nearly every question I asked was answered with something suggesting that I "just use COM." Of course, I wasn't familiar with this. It was "the old way" and I was using "the new way."
It was difficult to work past that, and you'll likely face the same issue here. Basically, when people have made a career out of doing something the one single way they know how, they tend to expect everyone else to know it as well and will cling tightly to it as their bread and butter. You can be better than that, but it'll require patience :)
I assume that your development experience included Windows Forms. In terms of the transition from Windows Forms to ASP.NET WebForms, there's no doubt that would be an easier transition. Whether that would be the best transition is another question. And I believe the answer is without a doubt, no.
MVC allows you to gain an understanding of the way the Web works. Understanding GET and POST, Requests and Responses, not to mention HTML, CSS, JavaScript, et al.
I would not hesitate to recommend MVC.
I don't understand why you don't want to learn Web Forms. Learning Web Forms is just like learning abc's. You'll learn it as you go along with MVC. My suggestion is, Just go with the flow in your learning of MVC and you'll be surprise that you're already learning Web Forms.

Is there a drawback of using ASP.NET Dynamic Data for a data driven website?

I watched a little introduction into ASP.NET Dynamic Data, and I noticed this option to create a data driven website for the first time. I have a database with a few tables, just created a Dynamic Data application out of my database and well... my application with a lot of nicely looking web pages, navigation between them and all kinds of CRUD operations was finished after 3 minutes.
OK, seriously, it isn't finished of course. There is a lot of custom logic to introduce, design to change, and also pages or relationships to remove I don't want actually to see in the web application.
But now I am wondering if ASP.NET Dynamic Data is at least a viable starting point or do I better start from scratch and create page by page? I could imagine that it might be useful to create a quick database maintenance web interface but is it good for a very customized web application? Is it in the end more complicated to modify the scaffold than building up everything from the ground?
I'm very interested in your experiences or recommendations regarding Dynamic Data! Thanks in advance!
I could never wrap my ahead around it enough to get any use out of it. At first, I thought this was Microsoft's answer to Ruby on Rails, and I was looking for the same benefit. I don't it comes close to having the same benefits. When I then compare it to a CMS (DotNetNuke, Sharepoint, Drupal, etc) it then looks really underpowered. Compared to ASP.NET MVC, it seems like going the wrong way from basic ASP.NET (MVC is removing bad abstractions from ASP.NET, while DD is adding even more abstractions).
Personally I'd rather build something from scratch in ASP.NET MVC, though my day job is regular ASP.NET. I'm also learning Drupal as I haven't found the sweet spot with ASP.NET based CMSes. One thing at at a jobsite you're going to want to use technologies everyone else knows. So I think that limits where knowing Dynamic Data is generally useful, as basically any legacy application won't be using it and you're unlikely to find a team with existing ASP.NET Dynamic Data experience.
The quick scaffolding is spiffy but at the end of the day I don't think it will make web development easier.
I very like ASP.NET Dynamic Data as it is a fast way for creating data driven applications. Customization is not a complicated task.
I wrote a corporate website with this technology from the scratch - it takes appr. 2 months for all. So my point of view that this is a good starting point for web applications development.
if your archetecture resembles ASP.NET Dynamic Data or DotNetNuke or some other starter kit, go for it, if
application is small to medium sized
you do not have strict deadlines
you are learning the technology.
otherwise or when you will be skilled in particular technology, you will prefer yourself working from scratch as it gives you more freedom and space for the implementation of ideas.
For e.g, one reason for the breakthrough for Asp.Net MVC had was many .Net developers wanted freedom over the development / architecture / flow and rendering (HTML) of the product they were building. Asp.Net WebForms does provide solid and vast grounds for swift development and templates but developers had to go according to the architecture. This freedom is available under MVC and developers can make use of nearly all Libraries and skill set available and go their own way.
one successful sample is Stackoverflow.com itself
hope this helps

Do I need ASP.NET MVC?

I realize that ASP.NET MVC has all the hype. I have my doubts that I need it, but wanted to explain my potential project:
This is an internal LAN application. It is doing CRUD operations and a little reporting.
The user base is small (< 12 people) and there is not tons of data
There is not a huge number of screens (Maybe 20)
I don't care about URL rewriting
My view state is typically small (like a DealID or ClientID)
Even though I don't have a full mastering of Page Lifecycle, I do understand Postbacks and don't have a problem coding for it.
I believe in Layering and am familiar with the M-V-P pattern and other patterns.
I want to do some Unit testing, but heck 25-50% coverage is better then what most apps.
The app will have a little AJAX for search screens, but don't see it being overkill.
So what do you think? While using the "sexy" technology is cool, is it necessary?
No, it's not necessary. It sounds like you've already made up your mind. If the application isn't all that critical and you're more familiar with web forms, just do it the way you know how to. I think ASP.NET MVC is worth learning, but it isn't the right solution for every project. Go and try it out in your free time so that when this situation comes up again, you'll have more options available to you.
No you don't strictly need MVC but are you asking whether you should learn something new or use what you already know for an internal project? An internal project might be the perfect place to try out something new.
As was said, it's not necessary. However, if you're doing a basic CRUD application (and it sounds like you are), MVC would make that nice and easy.
You mention you're moving to project management. Do you think any of the projects or products you look into will be using MVC? If so then at least you'll have some familiarity by learning it with this small application. This means it is necessary, if you need it as a PM, but you do not require it just to build the app. It could run with anything you choose.
Incidentally, ASP.NET MVC is new, not MVC, not by any stretch of the imagination. I know you did not say it was, but you mention hype. I cannot help but think Java and other folks are saying, "We've been doing this for years and years."
You can use both.
Create a Visual Studio Web Application (not a website), and you'll be able to use both if needed.
You'll just need to add a reference to MVC and setup the routing.
Webforms and MVC
It's not necessary, no, but there's no reason why you can't use webforms or MVC.
If you feel comfortable working with webforms, then go down the webforms approach. If, however, you feel the need to broaden your knowledge of architectural patterns, then ASP.NET MVC is a pretty nice thing to use.
If unit testing is important to you, go with MVC. Everything else you mentioned, though, points to WebForms.

Has ASP.NET MVC made Web Forms a Legacy Platform?

Last week at Mix '09, the final version of ASP.NET MVC 1.0 was released.
Some of the stated benefits of this framework are:
Clear separation of concerns
Testability - support for Test-Driven Development
Fine-grained control over HTML and JavaScript
Intuitive URLs
Now, Microsoft are being careful to tout this as being "an alternative, not a replacement, for ASP.NET Web Forms", but given the advantages mentioned above, I'm wondering:
How long will it be until "classic" ASP.NET Web Forms is considered to be a "legacy" framework?
If you were kicking off the development of a new .NET web project today, why would you choose to use Web Forms instead of the ASP.NET MVC offering?
Good questions. I think ultimately, the answer is going to be the development team's expertise and the project needs that will decide that. ASP.NET web forms is so heavily used that it likely isn't going away anytime soon. Plus, there are so many custom controls and third-party support such as components and books. The main benefit of web forms is how easy it is to get a dynamic website up and going. It really is a RAD way of developing websites.
However, once that team has more experience with creating larger websites with much higher demands in terms of scalability, reliability, and test-ability, then they will look towards other solutions for that. In this case, they will realize that web forms are harder for unit-testing. They may also see that viewstates reduce performance and look for possible solutions.
Although MVC has the stated benefits, it is unlikely that anyone will convert their sites to use this new framework right away or ever. Plus, it requires the team to learn the new technology, and work out the new bugs. The team will have to learn new ways to do the exact same thing. For example, how easy is it to support uploading a file using MVC?
As I saw recently, there isn't a reason you can't create a site using MVC and web forms together. So you may see more hybrids in the near future. But I doubt that web forms will ever go away.
I kind of think about web forms like the way VB1 changed the way Windows applications are created on the desktop. To this day, the RAD way of creating application still exists and will never go away.
Keep in mind that MVC STILL uses WebForms for it's default View Engine. Sure, you can replace it with another one, but WebForms is still a core part of it.
Also, not everyone prefers to tightly control the HTML or the Routing. That's not my attitude, but some people just want their job done with the smallest effort.
And aren't .asmx Files technically part of the "old" Model as well? I can say for sure that a lot of people would not like to see them go away.
Still, I personally see ASP.net MVC becoming the main Web Engine for ASP.net in the future, although not in .net 4.0 yet.
You're asking when a newly-released web platform, ASP.NET MVC, will replace Web Forms, which has been around for seven years.
If we'd been crying out for ASP.NET MVC for the past seven years, then it wouldn't have taken seven years before ASP.NET MVC was released. The fact is, not everyone sees a need for this. Many of us have been creating complex, highly-scalable web applications for most of those seven years.
We even knew how to make them testable, and to separate presentation from business logic and data access. ASP.NET MVC may enforce this separation, but I've done it by using coding standards and code reviews, and by saying, "there's no unit test for that", and "get that business logic out of the UI".
Also, if I really needed more control of the HTML, I would write my own control to generate the HTML.
I do not believe WebForms will ever retire.
I've been using WebForms at work in business applications and MVC at home for some private things. Though I really like MVC I do not see how this could be possible to implement really complex UI logic with HTML/CSS/JavaScript. It will quickly become unmanageable and will be quite unsecure since JavaScript can be switched off to prevent disabling some controls or hiding some information. On the contrary, turning off JavaScript with WebForms will virtually turn the page dead for any action, either authorized or not.
Both platforms will continue to evolve. For general web sites and HTML/CSS lovers MVC is a way to go, with complex applications you would want object-oriented architecture and artificial event handling even though it abstracts you from the stateless nature of HTTP.
So, pick up what is best for you.
P.S. Dropping WebForms altogether will jeopardize the future of numerous projects and companies throughout the world. Microsoft folks would not want to become an object of hatred and the trigger that started the third world war.
WebForms will still have a place for those that want a pseudo-stateless web application that they can easily put together by dragging and dropping. For those that don't have to or want to understand how HTTP works. It's the ultimate in RAD for web applications.
ASP.NET MVC on the other hands allows much more finer control at the cost of more responsibility. You get complete control over your HTML however that means you have to sanitize/encode your output yourself. Your application for the most part has to be completely stateless and for some ASP.NET WebForms/Windows WinForms developers that it's a bit hard to wrap their mind around.
I don't think either will ever dominate the other though one may be favored.

Do you plan move from ASP.Net Web Forms to ASP.Net MVC?

If yes, when? and how much time do you think that the process will take to migrate your current projects (if it's the case)?
ASP.NET MVC is not meant to replace WebForms. They are different technologies and are designed for different purposes.
Making a blanket statement of saying that I'll only use one and not the other is a very narrow minded approach, as you're missing the pros and cons of each technology.
Microsoft is commited to both technologies going forward and there are quite a few sweet new features coming in WebForms 4.0.
I'll be using WebForms and ASP.NET MVC, but looking at the needs of the current project so that I make the right decision for the current implementation
I've been using it for a few months now. I absolutely love MVC. Converting existing projects may not be realistic, depending on available time. As I see it, Web Forms simulates windows forms development for the old VB crowd. While MVC doesn’t pretend it’s something it’s not and follows the Http process more closely.
A few plusses I see in MVC
1) It’s testable with unit tests
2) Direct control over Html. We make websites, how do we accept not being able to control all our html?
3) No viewstate baggage
4) No control tree to waste time rendering
5) Automatic binding of a modal from a form post
6) It can be rather sexy
And a few disadvantages
1) No more web controls (and many rich 3rd party controls are lost)
2) Slower to develop in
3) Large learning curve
4) Still in Beta (CTP soon though)
Yes for my new projects. But not for current production software.
Yes, in as orderly a fashion as possible.
MVC opens .NET up to the world of Best Practices for Agile development. It specifically addresses concerns about Separation of Concerns, and coupling/cohesion. It also lets us write more-portable software without creating a dependency on any vendor-specific references or components.
It unquestionably is a successor to WebForms, along with WPF, regardless of whatever PR you might read.
The Wikipedia entry is pretty clear, even before being updated for Microsoft's MVC.
Assuming you prefer ASP.NET MVC to Web Forms, it's worth it for a system that's in active development/maintenance.
They can coexist side-by-side, so it's possible to migrate parts of the application (new ones, or selected old ones) and see how it works out. If it's a success, keep going.
An "all or nothing" migration could be disastrous, though - investing a lot without quick feedback is a huge risk.
WebForms are for rich UIs
These can be done just the same with MVC or Webforms. A year from now rich MVC based toolkits will arrive (technically they're already here if you like YUI, ExtJS, etc.) and make this argument null and void.
migrate your current projects
Migrating an existing WebForms project to MVC doesn't make a lot of sense. What are you going to gain? Using MVC for a new project however can make a lot of sense depending on your requirements.
I was never really fond of WebForms to begin with so getting to work with MVC was like a breath of fresh air to me. I've always much preferred the separation of concerns as I could work on the chunks that I was really good at developing, the logic and the data access, and leave the presentation work to the members of the team who had that natural ability. I think the MVC library makes it easier for teams to work together on individual pages as one person can work on the controller and the other person can work on the view.
All that being said, when I'm working on projects where I don't need to focus as much on the coding and it is more display oriented, I still go back to the WebForms because they are so much easier to implement and get up and running. Both have their places and I don't think one will ever supersede the other.
I've been using ASP.NET MVC for several months now and I prefer it to Web Forms. However, I don't see myself migrating my existing projects to MVC. For me, it would be rather pointless. However, all of my new ASP.NET projects will (or should be) developed using MVC, as it is a much better (and more flexible) framework.
Personnaly I restricted ASP.NET MVC for lightweight Front Office Web Sites.
But still using ASP.NET WebForms for Righ BackOffice Applications to take advantage of rich custom controls and some of other nice features of Web Forms.
Another plus for mvc is that javascript like jquery is much easier to implement, so if you plan on using a lot of js, mvc might be the way to go.
No, there's no reason to. It's an alternative style, one I am not fond of. But that's just my opinion; a lot of people like it and I hope it works well for them.
As already said, they're not mutually exclusive, and I play to make good use of both.
IMO MVC is better for web sites, while WebForms are better for web applications.
For example, this site is a perfect showcase for where ASP.NET MVC is a good choice because of the nature of the site and what needs to be accomplished; other good examples would be a web store, or a project management site (like Basecamp), or a social network.
If you were developing a corporate CRM/ERP system, however, I'd stick with WebForms to get rich controls and a more "desktop-like" programming model, since a CRM application is traditionally the domain of a desktop application.
ASP.NET MVC fits my desired style of development better, but I'm wary of trusting myself to it whilst it's not been RTM. It also is different enough that our legacy code will not work with it. If we had been practising Domain-Driven Development things might have been easier, but ...

Resources