Does Silverlight 3 Change the MVC vs. Silverlight question? - asp.net-mvc

I'm starting a new project soon and investigating whether or not to use MVC, Silverlight or both. This question Silverlight vs. ASP.NET MVC was a good starting point. But looking over the SL3 beta, it looks like there are two things that change the landscape just a bit. First, the navigation feature which is a direct feature of Silverlight and now there is the .NET RIA Services. While not actually part of Silverlight, it's fairly integrated and seems to bridge the gap between client and server operations. An area, in my opinion where MVC is strong and Silverlight (being a client side technology) was not. I understand that you can still use both, but should you and why?

Simply put, no.
Silverlight and silverlight on the desktop are more like winforms/wpf applications that just happen to run on the web. They're stateful and act very differently from a web site. Silverlight apps can only be run on machines that allow silverlight to run. In a business network setup they may have group policies setup so that silverlight cannot be installed. Then you've got a problem.
ASP.NET MVC however is a stateless type of design where pretty much anyone with a web browser can get to regardless of platform. You have much more freedom with your site using ASP.NET MVC because you don't have a dependency on the end-user having any sort of runtime installed.
I think each has their place and it's pretty much obvious. Silverlight is great for creating a rich experience where applicable. I doubt you'll see too much silverlight popping up replacing web sites.

When we built .NET RIA services we looked to enable developers to basically build out rapid RIA's 100% and as a result we targeted the approach in terms of taken over the burden of ASP.NET WebForms etc. To use the two in a hybrid fashion is possible, but it's a question of which piece do you want to take over the heavy lifting.
If you're Silverlight solution is basic in terms of implementation - ie datagrid of data only - then ASP.NET MVC is a better fit as this way you're not having to worry about deep linking etc (as that comes free inside a native HTML based approach).
If however you're building out a larger RIA solution within Silverlight and are using ASP.NET in ways that are specific, then ok thats fine, but you're going to have to remember that with every page refresh comes a penalty that is of course a page refresh and secondly you need to ensure the said Silverlight instance can find its way back to where it was before you hit the refresh (that or loads in a place that enables the user to find its way forward).
It can be somewhat very tricky despite the goodness we baked into RIA Services.
Scott Barnes / Rich Platforms Product Manager / Microsoft.

I think that both technologies have their places - I think Silverlight will be used mainly for special purpose applications and asp.net MVC will be mainly for public and general purpose style webpages and web applications.
As to which one you want to use, well that depends entirely on your needs and your audience.

Silverlight is coming along nicely even for business applications (Navigation, RIA Services, Data Form etc...) But ya the big problem is the plugin.
Personally, I'm sick and tired of HTML so i'm focusing efforts on Silverlight.
It also depends if you're working on a site for fun or not.

A lot of websites built for businesses and organizations have a "read only" public facing front end. That is, information (inventory, catalogs, corporate news) are presented from a rich database, but the average end user has no ability to edit them.
The natural pattern I have been seeing is to use ASP.NET MVC for the "front end" presentation but to use the Silverlight / RIA functionality to avoid having to write all the CRUD stuff int he administration back end. It is a great fit. The administration userbase is usually much smaller than the total audience and issues of download time, Silverlight penetration and so on are not nearly as problematic.
However the Silverlight RIA / ASP.NET MVC story is a very fuzzy one right now. There isn't much information discussing how to use RIA Services to provide access to a shared repository project of the style you build for MVC projects. link text This makes integrating them difficult right now. You could build both your MVC and RIA layers on top of a common EF or Linq2Sql base but it makes sense to share the intelligence of the Repository classed you build for MVC.
Ideally, we will get good documentation of connecting RIA Services to a Repository style class layer, independent of what the Repository uses to talk to the database underneath and then the rapid development story will be complete.

I dont think silverlight changes the asp.net MVC story.
MVC lets asp.net be more web standard friendly, and forces projects into a more testable, decoupled structure. The later was the sole responsbility of the architect/developer in webforms.
"Personally, I'm sick and tired of HTML so i'm focusing efforts on Silverlight."
Amen to that. javascript too.
I've been developing web apps for over a decade (Classic asp then jumped to .Net as soon as it was in beta). MCTS x2 and MCPD x2 in asp.net.
While i think ASP.Net MVC is great additon for web site developers, i do think web forms with a strict MVP pattern in UI layer is often still better for enterprise / B2b web applications. (dashboard, administration, reporting etc.)
That all said as i move into more into the integration space, SOA, biztalk, wcf etc.
I really am over the giving a sh1t weather this css property is applied validly in "IE version what ever". or "firefox version whats next" and over dealing with the sometimes great sometime want to shoot myself control hierachy in web forms.
Silverlight 3 is really starting to become relevant for LOB applications, i see it as the major compeditor to webforms, not MVC.

Related

New Presentation Layer for Webapplication

we've got an existing webapplication written in magic. But now we eventually want to exchange the existing web-presentation layer (maybe also rich client) to a server side presentation layer. What do you think I should look first (ASP.Net MVC, Silverlight, something in PHP).
With which technology is the effort relativly small to exchange the presentation layer if you only have a model.
And is it maybe possible to use a generic presentation layer so that we could create the new pages with small effort.
PHP vs ASP (or anything other such as Ruby on Rails, etc) is all about preference and what you know or think you want to ramp up on. Let me talk about this from a Microsoft web developer perspective, assuming you choose to go down that path.
If you have a pretty simple data in / data out app, and don't need a lot of dynamic screen interaction and want to develop features quickly, then ASP.Net is the way to go. You can do a lot of dynamic stuff with Javascript and web services, but ASP.Net is not as flexible as something like ASP.Net MVC. However, its much easier to develop an entire screen quickly in ASP.Net using server side controls.
If you want greater control over your HTML output, you want a more dynamic display with Javascript, and want to be able to more easily leverage unit testing, ASP.Net MVC is the way to go. Developing simple screens will take longer than a traditional ASP.Net app, but developing interactive content where server generated DOM needs to mesh well with client-side manipulation will go faster with MVC. Unit testing is also a snap with ASP.Net MVC, and there are plenty of example out there to show how to build a well-tested MVC site. I would argue that ASP.Net MVC might also scale better since you have more control over the output.
If you need a really pretty UI with rich graphics and animation, and want to be able to unit test your application logic, then Silverlight using the MVVM pattern is the way to go. I am writing just such an app right now. Its pretty easy to unit test (as easy as any unit testing ever is), easy to mock out data to test the UI with large datasets, and Silverlight provides a level of graphics you cannot get in HTML. Having said that, you will be dealing with a smaller audience using Silverlight as the plugin is required to view Silverlight just like Flash. Silverlight isn't available on the iPhone as well. Silverlight also incurs a downloading time penalty, so you have to do some thinking about how big your app is which isn't so much the case with a "pure" web app.
A mixture of ASP.Net and Silverlight or ASP.Net MVC and Silverlight is your fourth choice. You might do this where only parts of your application require the rich UI that Silverlight provides. Silverlight and ASP.Net projects can share files, so you can use classes you develop for business logic in both places (with a few caveats).
I hope this helps, and good luck with your project.

ASP.NET MVC plus Silverlight

It seems to me that, for structured development with both depth and breadth of capability, ASP.NET MVC and Silverlight have the potential to make a nice powerful framework with superior UI granularity and reduced AJAX exposure. Have any of you tried building such a stack with future durability in mind?
ASP.NET MVC and silverlight?
In some ways, it is an either-or choice - your data is displayed either in html/css/js generated by ASP.NET, or in Silverlight. Why mix them? I'm sure that ASP.NET MVC is a good way to deliver Silverlight, but that doesn't necessarily make it part of the same UI.
It's generally about reach vs. richness. A web UI with no Silverlight or Flash can reach more users, but one with Silverlight can have a richer UI. Silverlight is good fun to code in, and I have seen some wonderful apps using Silverlight's streaming video features, but if e.g. you are doing data entry and display, and you don't need the richness of Silverlight, then why not keep the reach and stay in Asp.Net?
If you are going to do the UI in silverlight it makes sense to do all of it in Silverlight. I have had good experiences with all the ViewModel-view-controller page flow happening inside the Silverlight app, rather than transitioning to another html page and loading a different silverlight app. It's faster and you can do fancy transition or fade-in effects in Silverlight's XAML markup.
Why is "reduced AJAX exposure" a desirable goal? Sites like e.g. Stackoverflow here use AJAX techniques to very good effect.
Stephen Walther's talk at MIX09 shows four pillars of ASP.Net as it currently stands - Forms, MVC, AJAX and Dynamic data. A lot of people are Seeing it as "moving from forms to MVC" but there are other approaches also being developed in the mix.
I've built a little test app with SL and MVC. It didn't work that well but I don't think I was doing right. I've tried using SL in views but its slow to switch pages since its loading new SL instances all the time. I've tried a single SL app which meant it contained all the control code as well but that relegates the server to data access which only needs some WCF/Web service code no need for MVC there.
It may work better if we dispense with the idea of there being many view pages. In my next iteration I shall be using controllers to respond with XML or JSON directly to requests from a Silverlight app which contains the views. However this approach would still leave some questions unanswered, for example, how does the controller get to have a say in what view is actually displayed?
To be honest, I'm getting the feeling that SL to ASP.NET-MVC are yet shaping up as a good match. Some web apps may benefit from some SL elements (charting for example) yet the app remain firmly in HTML. On the other hand, an app whose UI is purely in SL (whilst internally using some similar View/Controller concept) doesn't really need MVC on the server-side.
Its early days, it will take while for us early adopters to see what really works and what doesn't. There being a beta for version 3 with more coming from MS in the way SL can access serverside data may change things further.
I asked a similar question here: Does Silverlight 3 Change the MVC vs. Silverlight question. This was in response to SL2 vs. MVC where folks all agreed that they were complimentary technologies. I'm still not convinced. My experience has been similar to AnthonyWJones. Per the previous posts, I tried to mingle them without a lot of success. Could be my own ignorance, though. Right now I'm building a Silverlight only application using SL3 beta. I seem to be a lot closer to my intended effect. That being, an application with a few database features. So it didn't make sense to build a completely stand alone app (since the data is central), but I really wanted some Silverlight goodness to render the end result and allow the user to interact.
So where in the hell am I going with all of this? Based on my experience, this still seems like a YMMV type question. It really depends on what you're trying to build. Since I'm light on database, heavy on interaction, I'm biting the bullet with Silverlight 3 and .NET RIA Services for the little database stuff. If I were writing Stackoverflow, I'd probably do ASP.NET MVC and AJAX.
We are currently using ASP.NET MVC as an alternative to WCF to expose data to Silverlight where our Silverlight app makes RESTFUL calls to urls in our Mvc application and the controller returns a JsonResult which works well for us. It's by no means necessarily the text book way but we found this way the two technologies compliment each other. Now if we ever need an HTML implementation we've already done the Model-Controller work which can be re-used.

How do you choose between an asp.net webform and mvc application?

This is a difficult question to ask because it's so wide ranging.
Does anybody know of a scoring system of questions that would aid in choosing between a WebForms and MVC application at the start of a project?
e.g. Is TDD an important part of this project? (If yes score 1 for MVC and 0 for WebForms)
I would consider the following:
Current Skill Set of the team. If you have a large team that aren't going to pick up MVC quickly but are comfortable with Web Forms I'd stick with Web Forms
What level of control do you need? MVC gives you more control but that also means you'll be doing a lot of extra things your self. WebForms gives you a lot less control but there are a lot more things in the box. If being able to control the HTML output is important to you than maybe MVC is a better fit.
Will you need third party integration? There isn't a whole lot of 3rd party control support for MVC however there is a ton of support for webforms. Getting a nice grid in webforms is simple, however you'll be writing a lot of your own code in MVC to solve that problem
As you mentioned, is TDD desirable?
State management is a lot easier in web forms
I have a single question test (disclaimer: it's far from perfect, but does the job a lot of time in making you lean toward each of the technologies):
Is your application more form oriented (e.g. intranet stuff or something) or you are building an Internet-facing Web site (e.g. StackOverflow). In the first case, I'd probably go with Web forms. The latter case is probably better satisfied by ASP.NET MVC.
Another thing: these two are not the only paradigms out there. Before MVC days, I've done several projects by building HTTP Handlers that do the routing and other stuff that MVC does. You could also strip the Web form part of ASP.NET and just use non-server-form Web controls (while you'd do it in a standard Web forms project, I can hardly call this style ASP.NET Web forms).
Unless you are working on a very data centric app and need server controls with databinding and viewstate, I would go with MVC.
I haven't made anything serious in web form since MVC preview 2. MVC is much better with regard to design patterns and best practices.
And yes IMO TDD is very important and gives more than 1 point to MVC.
Usually, the decision to use WebForms or MVC boils down to controls. If you are going to be using a lot of server-side controls, then WebForms is for you. If you don't have that burden then MVC, at least in my opinion, is much cleaner, and more testable.
After using both of them the way I decide now is: Do I need to use server controls? If I don't then I default to MVC.
If you were stuck with WebForms for some reason then you could implement the MVP (Model-View-Presenter) pattern to separate the view from the logic and have some hope of unit-testing the codebehind.

ASP.NET MVC - Is it viable for small web outfits?

I work for a small website company (couple of programmers, couple of designers). Currently we use ASP.NET website projects - this makes it easy for me to sort the programming out on my local machine, while the designers work directly on a development server and the 'on-the-fly' compilation allows them to see any changes made without having to compile and deploy the website (and all tied up with SVN).
I'd like to start using ASP.NET MVC for pretty much all the reasons that makes it different from Webforms (logical urls, no viewstate, more control over html, unit testing etc..) but don't want to make the dev process over complicated, so:
Any reasons you can't set MVC websites up as website projects instead of Apps so they don't have to be explicitly compiled throughout the dev process? (Our 'live' websites all use web compilation projects anyway).
Will this still allow unit testing?
Is there any other way of allowing the designers to develop MVC sites in the same way as they currently do? Note: They use Dreamweaver, so no Cassini development server.
Can anyone advise with any of the above (even if only to tell me my dev process makes no sense.. :)
Thanks.
ASP.NET MVC is a great platform no matter what type of project. If you already understand the basics of HTTP and how websites actually work ASP.NET MVC will be like the thing missing from your life. If you're used to the postback model of ASP.NET WebForms it may be a little harder to grasp at first but it's very easy to understate. It's basically a stateless model. Your controller is given some parameters, it writes back some HTML... end of story until the next request.
I don't think so, and I think the reason for this was to allow bin-deployable ASP.NET MVC projects. You can publish an ASP.NET MVC app straight from Visual Studio 2008 without the end server ever even having to know about ASP.NET MVC, as long as it has ASP.NET 3.5 (with SP1 I think)
ASP.NET MVC is all about unit testing, it's extremely flexible in this matter and even some of the design decisions behind ASP.NET MVC are based off allowing users to unit test their code. Scott Guthrie specifically names unit testing in the latest release of ASP.NET MVC (beta) http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-released.aspx#six
Any controls that work with ASP.NET WebForms will work with ASP.NET MVC as long as it does not rely on postback. If it does than you cannot use that control/code.
MVC is a proven design pattern for websites and even the very one you posted your question on is based on ASP.NET MVC and was built by only a few people and is now maintained by 1 (one) person (soon to be 2). I currently am using it for 3 private projects and I love it. I've seen the light and I will never go back to WebForms.
Resources:
Scott Guthrie's blog
Phil Haack's blog
Rob Conery's blog He has created an MVC Storefront demo over 25+ videos.
Scott Hanselman's blog
Stephen Walther's blog
PDC08 ASP.NET MVC Session Session was with Phil Haack and Jeff Atwood (creator of this site).
HTH!
I used to be an ASP.NET developer. Recently I started developing with Django and do so with one other developer remotely via SVN. I find that MVC frameworks make small projects even easier, and larger projects a lot less painful than oldschool ASP.NET did.
Templates are far easier to control and style than the web controls in ASP.NET. Separation of logic (beyond the code-behind methodology) makes it easier for more than one person to be working on different parts of the site at the same time. RESTful design centered around actions starts making a lot more sense after having to deal with ASP.NET page life cycle issues long enough. Also, the URL-driven routing and the ability to do reverse lookups means fewer hard coded links in your code, its easier to add new sections to your site, etc.
To answer some of your questions:
I'm not sure about live compilation, but its easy enough to write some simple deployment tools to automate this process.
Unit testing is often easier on an MVC framework thanks to actions in controllers compartmentalizing the logic much better.
ASP.NET MVC allows you to use webforms as the default template language, but I'd advise looking into cleaner templating languages such as NVelocity. Any HTML-centric templating system is going to be better than webforms because of how difficult it is to tame and style even simple aspects of web controls.
This site uses MVC. I think the team behind StackOverflow qualifies as a small shop. They have a lot of experience though. Still, considering how many people are involved (a few) and the number of servers, yeah, it's small. And it runs very well in my opinion.

Is ASP.NET webforms swept under the rug to make room for mvc?

I've read all the marketing speak about how mvc and webforms are complementary etc...
However it seems that all the blogs talk about is mvc and the only news coming out is about mvc.
Is Microsoft going to continue to IMPROVE webforms as a first class citizen or will it just be a supported technology as they move all their real efforts, developers and resources to mvc over time?
Is there any real evidence of any new exciting improvements coming to webforms in the near future?
You could do worse than take a look at Phil Haak's post from November:
The Future of WebForms and ASP.NET MVC
He points out 5 key things anounced under ASP.NET at PDC last year:
Core Infrastructure including scale and performance
Web Forms including issues with Client IDs, ViewState, CSS use, etc
AJAX
Data and Dynamic Data
MVC
Coupled with that, there are things that have been built as part of ASP.NET MVC that have already been released for webforms like the Routing module which is going to be great help in some of my projects, even without using MVC.
On top of those, there are also a number of changes coming in VS2010 that should help web developers using either WebForms or MVC, which would be good.
Bloggers tend to talk about what is shiny and "new", that's the way things go - you're bound to see a lot of words written about it because of that, although MVC is hardly a new design pattern - it goes back at least 30 years.
The same could be said of WPF/Silverlight - are they WinForms/WebForms killers? No. They are alternative offerings, with some benefits over the earlier way of doing things, but also with some differences/drawbacks.
I was at a conference (Remix 08) and Scott Gu said they will definatly be continuing to support both methods and that MVC was not appropriate for every application. Scott said there were a number of coming improvements for web forms model (although didnt say what they were).
The web forms model will not disapear because:
Web forms model is better for some types of applications, e.g. small apps, those requiring long processes that make use of view state useful
Many applications are using it
Many third party components developed for it
ASP.net implementation is not mature yet (although does seem pretty good so far)
Microsoft will probably announce a number of new features in PDC in a few weeks time.
Microsoft is finally coming to terms to one basic fact of development. You can't provide the ultimate solution to any problem. This is why MVC is being developed, and Scott Guthrie is clearly stating that MVC is meant for larger, more enterprise-y sites. Web forms will continue to exist and be developed as a simple, RAD-based approach to web development.
If you take a step back and review all recent improvements and additions to the Microsoft stack, you can quite easily categorize them between these two classes. For example:
Data access: LINQ-to-SQL vs EntityFramework
Remoting: WCF vs WebServices
LiveID: LiveID (web) authentication vs RPS authentication
...
I only hope that Microsoft will make this distinction clearer with time, because there seems to be a lot of confusion among developers as to what tool should be chosen for which task.
In conclusion, I think that Microsoft will keep on developing both because they cater to different developer profiles. Microsoft has obviously a lot of interest in growing its developer base as much as possible and to make the .NET stack as useful as possible.
I am going to go out on a limb here and disagree with the general idea that MVC is the "enterprise" framework here or is somehow the better of the two.
MVC is great! But just look at the name. It stands for "Model, View, Controller"... see the "view" in there?
Now look at the competition, "Web Forms"... see the "forms" in that one?
MVC does a great job in "view" type situations. For sites that publish content ("views" of information) MVC probably has an edge, especially for larger systems that need a lot of testing and very a formal design to support intelligent view switching.
For applications that interact heavily with the user via forms (data collection and data entry heavy apps) web forms has an edge due to the inherent use of form posts as a primary mechanism.
While you can do views with web forms and you can do forms with MVC, each has trade-offs. In the current state of MVC, I find that writing heavy data entry "views" is much more difficult and painful than with web forms... and I don't mean a little bit.
In the future I do expect to see MVC get better with dealing with data entry scenarios, but these scenarios will likely come at a pretty high price compared to doing those with web forms.
Neither is more "enterprise" level than the other as far as I can tell... what I'm most interested in going forward are hybrid applications that use MVC for the display and publishing end of the business while web forms are used more naturally for heavy data entry end... all in the same web project... I sure hope we see something like that.
Before word of the MVC framework started spreading, we spent a good deal of time at my company developing our own .NET MVC framework.
This was because we didn't want to be constrained by the limitations of the WebForms abstraction - we wanted to avoid the 'clunky' feel and user interface compromises that WebForms seems to impose on all by the most heavily customised applications. Also, we wanted friendly URIs and we wanted a better separation of front-end and back-end development than that offered by WebForms (we settled on an XML / XSLT architecture).
In my opinion, WebForms in fact offer a much poorer method of interacting with the user specifically due to the use of ViewState, PostBacks, etc etc that abstract the actual mechanics of HTTP from the developer - this gives them less latitude in how they allow users to interact with the system. The classic example is that because WebForms pages are almost always the result of a POST, if the user attempts to refresh the page, the user gets a nasty warning message from the browser. The pattern in the traditional web development world for dealing with this has always been to include a 302 Redirect directive in the HTTP Response, thus sticking to the original HTTP paradigm of GETs being for retrieving data, and POSTs being for sending data. Other, similar problems exist such as the inability to have two forms on a page (for example a login form to a website on a different server).
That said, for RAD, WebForms are brilliant. I'm currently developing the admin application for a webapp we've developed using our custom MVC framework, and I'm flying through since all I need is to display the contents of a load of database tables, and in some cases allow the user to edit them, in various different ways.
I think that if we need to convince ourselves that MS are going to continue to support WebForms - just think of all the ex-Windows developers. These are the people that WebForms was originally developed for, and they're not going away. Corporate developers will be your saviour if you're a WebForms fan.

Resources