Advertisement

Integrating Silverlight and ASP.NET MVC

[previously named "Silverlight as the V in ASP.NET MVC" but changed per comments]

One thing that I’m excited about is learning new technologies.  Moving to the Silverlight team, I’ve moved away from a breadth of technology knowledge to something a bit more narrow.  Now I feel like all other developers trying to keep up with the technologies we are releasing.  As such, I’m a beginner for most.  One such technology is ASP.NET MVC, which was just released to release candidate stability.

I thought I’d play around with it in the context of Silverlight and use Silverlight as the “view” in the model-view-controller concept.  It’s easy to link the two.  In fact when you create a new Silverlight project, you now have the option of creating an ASP.NET MVC application as the host:

So right from the beginning, you can marry the two together.  Now from here, how can we leverage Silverlight as a view.  Well, here’s my take…learn with me (and comment where you’d do it differently/better and why).

First, I’m still going to create my MVC architecture.  I’m using the Northwind database for simplicity sake in this learning task.  I’ve created a LINQ to SQL data model to that database (which is a local SQLExpress instance).  I then wanted to take the simple task of showing the products by category and displaying them in a simple Silverlight application.

NOTE: Yes, this Silverlight view is basically just a layout of ListBoxes, but remember, this is just a learning experiment for us.  You may also ask yourself about Authentication/Authorization…again, this post is about an experiment and not a full-featured implementation, so there are bound to be missing pieces.

I decided to create a CategoryController and a ProductController which would handle the actions to retrieve list of categories and products and then drill into the detail of a product.  From there I still need some web View to be a container for my real view, the Silverlight application.  I created a View for Category, since essentially that’s the initial view my user would see.  All it is is an index page hosting my Silverlight application:

   1: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="SilverMvc.Web.Views.Category.Index" %>
   2: <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
   3:     <p>
   4:         <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
   5:             <param name="source" value="ClientBin/SilverlightWithMvc.xap"/>
   6:             <param name="onerror" value="onSilverlightError" />
   7:             <param name="background" value="white" />
   8:             <param name="minRuntimeVersion" value="2.0.31005.0" />
   9:             <param name="autoUpgrade" value="true" />
  10:             <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
  11:                  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
  12:             </a>
  13:         </object>
  14:     </p>
  15: </asp:Content>

Now all I have to do is start building my real view that will be here, the SilverlightWithMvc.xap application.  But first I obviously need my controllers to respond so some requests.  I wanted the CategoryController to display a list of categories and a list of products associated with a category.  But remember, my View will not be the ASPNET View, but rather my Silverlight app.  How then could I get the ViewData to be sent to my Silverlight application.

In MVC, typically your code will return a View from the action, similar to my Index view in my CategoryController:

   1: public ActionResult Index()
   2:         {
   3:             return View();
   4:         }

See where the return is an ActionResult (common) and the return is a View, also common.  This return would expect that there would be a View named Index in the project hierarchy, which in our case there is and again, is the initial hosting page for our app (located in /Views/Category/Index.aspx).  But what about our other data.  I wanted to add a controller action called List and Products that would list all the categories (List) and then list all the products for a given category (Products).  But I just wanted the data.  It turns out that the MVC framework can give us just the data instead of the View.  There is a Json return type.  So using my LINQ queries I created the two actions:

   1: public ActionResult List()
   2:         {
   3:             NorthwindDataContext db = new NorthwindDataContext();
   4:             var cats = from cat in db.Categories
   5:                        select new
   6:                        {
   7:                            cat.CategoryID,
   8:                            cat.CategoryName
   9:                        };
  10:  
  11:             return Json(cats);
  12:         }
  13:  
  14:         public ActionResult Products(int id)
  15:         {
  16:             NorthwindDataContext db = new NorthwindDataContext();
  17:             var prods = from prod in db.Products.Where(cat => cat.CategoryID == id)
  18:                         select new
  19:                         {
  20:                             prod.ProductID,
  21:                             prod.ProductName,
  22:                             prod.UnitPrice,
  23:                         };
  24:             return Json(prods);
  25:         }

As you can see the return type is Json and passing in the model data of what I need…as opposed to saying return View([modelData]).  I now get Json formatted data as a return result.  Great, now how to consume them?

Within Silverlight, we know we can consume Json data and we can take advantage of that capability to bring MVC and Silverlight together.  First let’s look at my layout UI code for the Silverlight application…it’s basically going to be a cascading ListBox view:

   1: <UserControl x:Class="SilverMvc.Page"
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   4:     <Grid x:Name="LayoutRoot" Background="White">
   5:         <StackPanel Orientation="Horizontal">
   6:             <StackPanel Orientation="Vertical" Margin="0,0,25,0" x:Name="CategoryListing">
   7:                 <TextBlock Text="Select a category..." FontWeight="Bold" />
   8:                 <ListBox Width="200" Height="150" x:Name="CategoryList" ItemsSource="{Binding}" SelectionChanged="CategoryList_SelectionChanged" />
   9:             </StackPanel>
  10:             <StackPanel Orientation="Vertical" Margin="0,0,25,0" x:Name="ProductListings" Visibility="Collapsed">
  11:                 <TextBlock Text="Select a product..." FontWeight="Bold" />
  12:                 <ListBox Width="200" Height="150" x:Name="ProductList" SelectionChanged="ProductList_SelectionChanged" />
  13:             </StackPanel>
  14:             <StackPanel Orientation="Vertical" x:Name="ProductDetail" Visibility="Collapsed">
  15:                 <TextBlock Text="Product Details:" FontWeight="Bold" />
  16:                 <Grid>
  17:                     <Grid.RowDefinitions>
  18:                         <RowDefinition Height="Auto" />
  19:                         <RowDefinition Height="Auto" />
  20:                     </Grid.RowDefinitions>
  21:                     <Grid.ColumnDefinitions>
  22:                         <ColumnDefinition Width="Auto" />
  23:                         <ColumnDefinition Width="Auto" />
  24:                     </Grid.ColumnDefinitions>
  25:                     <TextBlock Grid.Column="0" Grid.Row="0" Text="Product Name: " />
  26:                     <TextBox Width="200" Grid.Column="1" Grid.Row="0" Text="{Binding Path=ProductName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" HorizontalAlignment="Left" VerticalAlignment="Top" />
  27:                     <TextBlock Grid.Column="0" Grid.Row="1" Text="Unit Price: " />
  28:                     <TextBox Width="200" Grid.Column="1" Grid.Row="1" Text="{Binding Path=UnitPrice, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" HorizontalAlignment="Left" VerticalAlignment="Top" />
  29:                 </Grid>
  30:             </StackPanel>
  31:         </StackPanel>
  32:     </Grid>
  33: </UserControl>

Where one selection drives the next portion of the layout, etc.  You can see that I have several {Binding} statements in there as well as some selection changed handlers.  Let’s look at what happens on Loaded of the app:

   1: void Page_Loaded(object sender, RoutedEventArgs e)
   2:         {
   3:             WebClient mvc = new WebClient();
   4:             mvc.OpenReadCompleted += new OpenReadCompletedEventHandler(mvc_OpenReadCompleted);
   5:             mvc.OpenReadAsync(new Uri("http://localhost:33828/Category/List"));
   6:         }

You can see that I’m making a WebRequest call to a URI that happens to be our CategoryController with the List action command.  On the return event handler I’m getting that stream of data, which we know to be Json data, and setting the DataContext of my first ListBox:

   1: void mvc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
   2:         {
   3:             DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(List<Category>));
   4:             List<Category> cats = (List<Category>)json.ReadObject(e.Result);
   5:             CategoryList.DisplayMemberPath = "CategoryName";
   6:             CategoryListing.DataContext = cats;
   7:         }

Now you may at this point be asking a few questions about some of my decisions here within Silverlight.  First, the use of DataContractJsonSerializer.  Where is it?  Add a reference to System.ServiceModel.Web and you’ll get it.  You can also see that I’m using the ReadObject method and casting it to a List<Category>. 

Why not use System.Json and LINQ to JSON?  You could absolutely.  In doing so you could use your LINQ skills and get the data out of the Json stream and put it into a new object.  You’ll still have to create a local class representation because Silverlight can’t bind to an anonymous type.  This is the first reason I like just using the serializer.  The second reason is size.  I don’t know why I’m so picky, but I am.  Using the DataContractSerializer method here, my app is about 7K.  Adding a reference to System.Json and using those methods, my app is 27K.  For me, there is no additional benefit in code for what I’m doing to add that extra size, so I choose not to.  But you can…absolutely.  Your application needs may be different and the size cost/benefit analysis may result in a different outcome than mine…but there, I’ve stated my reasons here.

Where is Category defined?  Great question!  Category is a class defined in my Silverlight object that maps the data to a strongly-typed class..here’s the class definition:

   1: public class Category
   2:     {
   3:         public int CategoryID { get; set; }
   4:         public string CategoryName { get; set; }
   5:     }

Now that that is done, my data is retrieved, typed and bound to my UI.  Then in the category ListBox when a category is selected, we trigger a similar event to retrieve the products within that category and populate the product list using the same technique.  The final stage is that when a product is selected we populate a simple UI to show the details.  We could also have called another controller action, but here since we had most of the data in the product listing, we simply push the data to the DataContext of the layout container for the details:

   1: private void ProductList_SelectionChanged(object sender, SelectionChangedEventArgs e)
   2:         {
   3:             if (ProductList.SelectedIndex > -1)
   4:             {
   5:                 Product p = ProductList.SelectedItem as Product;
   6:                 ProductDetail.DataContext = p;
   7:                 ProductDetail.Visibility = Visibility.Visible;
   8:             }
   9:         }

You can see we get the SelectedItem as a Product (another internal class like Category) and make it the DataContext of the ProductDetail StackPanel who’s children have binding instructions.  The end result is this “view” below (the headings above the list boxes are not in the UI, but rather just labels to map to the controller action used to populate:

As I completed this little experiment, several things did come to mind…

  • What about deep linking?  The URI in the app didn’t change.
  • Now that I’m looking at a detail view, does the URI stating the initial view matter?

I think mostly these are “simple” things, but important to an MVC developer audience.  The interaction of URI semantics with Silverlight are important and things we are addressing in Silverlight 3 to make even this simple experiment easier.

So tell me, ASP.NET MVC experts, does this make sense?  Good/bad/what would you do different?  Help me learn how you would make the interaction between ASP.NET MVC and Silverlight better?

You can download my sample code for this project here (requires SQL 2008 and VS2008 with Silverlight and ASP.NET MVC tools installed): SilverlightWithMvc.zip


This work is licensed under a Creative Commons Attribution By license.

  1. 2/9/2009 5:06 PM | # re: Silverlight as the V in ASP.NET MVC
    I'm no ASP.NET MVC expert, but I like your approach. One could argue that your SL code is not pure view code, as it calls your server, etc. even though it only does this on Page_Loaded. Could you pass in the data model as part of the embed code?

    Alternatively, move the M and C over to the client as well. Obviously your model would make calls back to your web services, similar to how a server side model makes calls back to a database.
  2. 2/9/2009 5:15 PM | # re: Silverlight as the V in ASP.NET MVC
    So how would you go about posting the data back to the Server? You could send back the data Form Encoded. I don't think that the asp.net mvc DefaultModelBinder doesn't support deserializing json.

    I wonder if using mvc could be nice because you could build functioning prototypes in html, then without to much effort swap them out with Silverlight views.

    Cheers
    Jake
  3. 2/9/2009 6:12 PM | # re: Silverlight as the V in ASP.NET MVC
    Hi!

    Why good is it?
    I preferred prism v2 for silerlight (mvp technology in client side, automatic modularity, etc)
    I think better way to create a modularable silverlight architectura, and transfer data over wcf.

    Prism v2: http://www.codeplex.com/CompositeWPF

    Sorry for my english :)
  4. 2/9/2009 6:32 PM | # re: Silverlight as the V in ASP.NET MVC
    I think you are breaking the whole MVC Pattern. You can probably have a similar thing in Silverlight which consist the Model/View/Controller, maybe your Model is calling the Server Side Service. But you cannot imply the Siverlight is serving as a View for ASP.NET MVC (as it acts more like a model/controllar than view)

    If you post titled was Integrating Silverlight with ASP.NET MVC I would rather appreciate.
  5. 2/9/2009 7:31 PM | # re: Integrating Silverlight and ASP.NET MVC
    Michael: good point. I suppose a "pure" view would just receive the data. This could be done with Silverlight still, but maybe my implementation here isn't the best example, because the resulting 'view' still has functionality.
  6. 2/9/2009 7:33 PM | # re: Integrating Silverlight and ASP.NET MVC
    Kazi you have a great point here (and I renamed to be more accurate). How is it though that it breaks the *whole* pattern? Isn't the ASPX page itself just a View...in that sense that's what I'm trying to accomplish here...having a Silverlight app be a View. Perhaps in the current implementation of Silverlight this isn't the purist approach, but if the application was modular (i.e., if each of the lists was in fact their own control) it would be more of a View pattern.
  7. 2/9/2009 7:39 PM | # re: Silverlight as the V in ASP.NET MVC
    Where can I learn more about ASP.NET MVC? Oh No No No ... Microsoft, again another new technology to learn? oh NO NO NO NO NO ...

    I will complain to obama :-)
  8. 2/9/2009 7:46 PM | # re: Integrating Silverlight and ASP.NET MVC
    Rick, ha! But if you're serious, I'd check out http://asp.net/mvc as well as http://www.stephenwalther.com for great resources.
  9. 2/9/2009 8:06 PM | # re: Integrating Silverlight and ASP.NET MVC
    Good stuff Tim, I blogged about a similiar approach last summer:
    http://blogger.forgottenskies.com/?p=125

    My controller resulting an xmlresult and Silverlight taking those results and populating a XDocument (Linq to XML) type approach.

    I also wondered the same thoughts - ie. 'isn't Silverlight just a RIA view where I want to write C# code and not deal with uncompiled jQuery ajax calls that are hard to track when the app gets complex'

    But, I'm glad to see this piece. I just picked up John Papa's Silverlight book, and I think that I might push this all back a layer:

    1. MVC - the controller calling the ADO.NET data services
    2. Silverlight - acting more as a controller/view that calls the ADO.NET data services

    But really, having the Silverlight as the view makes a ton of sense to me, because the controllers also allow me to create DTO objects that can be exchanged with services past the controller.

    Just one more commment: Silverlight MUST fix this blurry font stuff - Silverlight looks great until you have to read the text. I'm leary of deploying it as I know my customers will start complaining about the blurriness of the fonts. (Especially black font on white background)
  10. 2/9/2009 8:23 PM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks, for changing the title. Now it makes complete sense.

    The problem with Silverlight as View:

    In MVC the View should not know from where it will get the data, the controller should be responsible for getting that from model for the view. Which is not possible with Silverlight. More specifically when you are calling the server side service in the Silvelight Page_Load it breaks the pattern as the view takes the responsibility to locate its data. The best option would be:

    1. Silverlight View Loads, It initialized its Presenter.
    2. The Presenter Calls ASP.NET MVC Controller.
    3. The Presenter instructs Silverlight View to show some kind of Progress
    3. ASP.NET MVC Controller prepares the data (It is the view in this case) from Model.
    4. The Asp.net MVC Controller returns the View.
    5. The Silverlight Presenter receives the data.
    6. Silverlight Presenter instructs the silverlight view to update itself.
  11. 2/9/2009 8:53 PM | # re: Integrating Silverlight and ASP.NET MVC
    Pardon my ignorance, but why is everyone arguing semantics here and trying to "fit" a Silverlight plug-in into the MVC model? I consider them seperate design architecture implementations.

    The ASP.NET MVC application will be the "host" for the Silverlight application. The Silverlight application itself is more than likely designed the MVVP pattern (if you had the foresight to use ASP.NET MVC). Why try to fit one into another?

    I consider the Silverlight XAP file completely modular and able to be hosted in a variety of places. I can host it in a ASP.NET web forms page. I can have my Silverlight XAP file hosted as a web part. I could have it hosted in Azure/Mesh. I can have it hosted in Silverlight 3 Mobile. Each time I change hosts, I should redesign my Silverligh module? I prefer to have that exact modularity and keeping the app to itself.

    For example, if I want to host my Silverlight XAP in a Web part I will wrap it with: web part properties, personalization, connection information etc. These probably should be in their own seperate "wrapper class".

    Isn't that what Silverlight is supposed to be all about? In my opinion, if you are writing for "one single host type" you might as well be writing Flash.
  12. 2/10/2009 5:29 AM | # re: Integrating Silverlight and ASP.NET MVC
    I don't think that using SL like a view is a pretty good idea. Moreover, I'm still thinking, that it is not an actual ActionResult - it has to use additional web request instead of obtaining data directly from controller - there is no big sense in artificial widening of "MVC", the worst from 2 of worlds - thick-client-driven and thin-mvc-driven =(
  13. 2/10/2009 7:07 AM | # re: Integrating Silverlight and ASP.NET MVC
    Prism v2! Prism v2! Prism v2! Prism v2! Prism v2! Prism v2! Prism v2! Prism v2!

    Why do you want use serverside controller?

    http://www.codeplex.com/CompositeWPF

  14. 2/10/2009 9:38 AM | # re: Integrating Silverlight and ASP.NET MVC
    Kazi: I think I actually agree that perhaps if one was to follow a pattern the MVP or MVVM model would fit 'better' for Silverlight. But let me ask you this. ASPNET MVC includes a set of Ajax helper methods that communicate back to the server using javascript/async and are in the View. Has anyone ever argued then that the use of these in a View make these no longer Views?

    meowth: see my comment to Kazi above. Are we entering a discussion of 'pure' MVC versus other interpretations perhaps? Similar to hi- and lo-REST definitions...but both are still REST?

    Oh, and let's pre-empt interpet's reply: PRISM V2!!! :-)
  15. 2/10/2009 3:43 PM | # re: Integrating Silverlight and ASP.NET MVC
    An MVC view can contain any type of view logic (or view widgets). Embedding Silverlight in an MVC view does not break the MVC pattern. Conceptually, it is no different than using Ajax in an HTML page to make asynchronous requests back to the server. In fact, you could switch out the Silverlight for an AJAX enabled HTML page in Tim's sample code and get something that everyone would agree is a perfectly fine example of an MVC web application.
  16. 2/10/2009 4:56 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim,

    excellent post. It is exactly I need to my diploma paper.
  17. 2/10/2009 6:19 PM | # re: Integrating Silverlight and ASP.NET MVC
    I liked the article, thank you Tim!
  18. 2/11/2009 12:02 PM | # re: Integrating Silverlight and ASP.NET MVC
    I need a good article on Silverlight with Prism V2 :)
  19. 2/11/2009 12:07 PM | # re: Integrating Silverlight and ASP.NET MVC
    oh, I should say on Prism V2:

    It's all geared toward WPF and not Silverlight.

    ie. 'hello world' app, etc...

  20. 2/15/2009 9:07 PM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks for this great post Tim, I've always wondered how MVC would go with Silverlight and databinding, and this is just as simple as using MVC in a classic pattern way!,

    Cheers
    Steve
    silverlightcoder.net
  21. 2/17/2009 1:16 PM | # re: Integrating Silverlight and ASP.NET MVC
    @Steve,

    There is quite a lot of Silverlight in Prism V2 now (Drop 10) perhaps you had an earlier drop?

    The team have done an excellent job of using a common code base for both a WPF and Silverlight library but some of the Silverlight documenattion needs to catch up.

    Jason
  22. 2/24/2009 10:10 PM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks for the first take on what I am sure will be a popular design pattern. I am going to create an application for a client using some of these techniques. Maybe I can improve on what you have started.
  23. 3/5/2009 12:20 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim,

    While integrating Silverlight into my MVC application I encountered a problem where the Silverlight dlls are not copied to the bin directory of my MVC application. Do I have to do something special to get these dlls copied?
  24. 3/5/2009 9:47 AM | # re: Integrating Silverlight and ASP.NET MVC
    Gugulethu there are no Silverlight dlls that are on the server -- Silverlight is a client-side technology.
  25. Gravatar
    3/9/2009 9:37 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi All,

    I've taken a different approach and found a way of integrating Silverlight and ASP.NET MVC by passing model data in via Silverlight's InitParams.

    I've blogged about it here if anyone's interested: blogs.msdn.com/.../asp-net-mvc-silverlight.aspx

    Thanks,

    (tim, keep up the great posts)
  26. 3/24/2009 5:26 PM | # re: Integrating Silverlight and ASP.NET MVC
    Tim,

    Thanks for the post. By the way can you give a small example of how you would post data from a Silverlight Client to a ASP.NET MVC backend. Tried using Silverlight WebClient using UploadSringAsynch and tried to get the posted data values on the ASP.NET MVC backend using Requst.Form["name"] ... without any luck. Moreover, it appears that my Request Object does not get populated with any data fro the "string" that is suppose to be posted from silverlight Webclient.

    Regards,

    BillC
  27. 3/25/2009 4:00 PM | # re: Integrating Silverlight and ASP.NET MVC
    Arggg!

    MVC = URIs are resources, not applications and asynchronicity is the name of the game.
    Silverlight = applications on the client via the plugin model and a URI is just an entry point into the application where it's ability to perform synchronous activities on the client an incredibly powerful and interesting technology.
    Web forms = applications over the server and a URI is just an entry point into the application. Synchronicity is encouraged through viewstate and session state. Like Silverlight, it's about making the stateless web seem stateful, but through server-side code.

    Web forms and Silverlight go together, because they share the same purpose, which is to provide an experience over the web that is similar to the one that you get on the desktop.

    MVC is about something else entirely. MVC is about statelessness and resources, not applications. Some Ajax makes sense, such as dynamically populating listboxes(as you've done in this example) or a treeview, but it should be used carefully, because once you start down that road, you end up making an MVC URI become an application, instead of what it's meant to be, which is a resource. In essence, you risk making MVC just Web Forms under another name.

    We already have Web Forms and there's no reason to try to fit Web Form behavior into MVC just because we can. Don't try to fit a square peg in a round whole, just because you've got a sledgehammer and some duck tape lying around.
  28. 3/25/2009 4:32 PM | # re: Integrating Silverlight and ASP.NET MVC
    John -- help me understand why providing a Silverlight UI is any different than providing an HTML UI to the same data?
  29. 3/25/2009 8:49 PM | # re: Integrating Silverlight and ASP.NET MVC
    "John -- help me understand why providing a Silverlight UI is any different than providing an HTML UI to the same data?"

    Suppose you were designing CBT training software and decided to use both MVC and Silverlight. You have dozens of pages of content. In addition, you ask the user 100 questions. Silverlight or Flash would seem to be a good fit, because users learn best when you can incorporate interesting visuals. The problem lies in the question about the state of a user's progress in the course. Silverlight, Flash and/or Ajax encourage you to keep state around. They encourage you to avoid the postback, because postbacks cause the screen to be re-drawn, which never looks good to a user.

    MVC, on the other hand, does encourage you to do a postback for each question, because each question is a resource and naturally map to the question id. In MVC, you would expect to be able to navigate directly to a question by enterring a URI that looks something like MyCBT.com/questions/5.

    With Flash, Silverlight and Ajax, you expect to go into the application and then it would be the responsibility of the application to provide you with a way to navigate to question 5. The two technologies go entirely in different directions. In MVC, you would either need to store the state of previously answered questions directly into the database after being answered or pass them to your DAL (e.g. NHibernate) to handle. In Silverlight, Flash, and Ajax it becomes easy just to keep adding state.

    So what's the answer? In the case of the CBT course, use Web Forms, not MVC. Web forms were designed to make the stateless web appear stateful, which is what a CBT course needs. The same would be true for a game, where each move of the game adds meaningful state to the game.

    MVC is a very popular topic right now and I admit that I'm personally excited about using it within my company, but I don't think that it makes sense with RIAs. RIAs are better served by Silverlight and Web Forms.

    Silverlight is peanut butter and Web Forms are jelly. They make sense together. MVC is like bananas. Sure, Elvis like to make peanut butter and banana sandwiches, but for the rest of us, doesn't peanut butter and jelly sound a whole lot better?

    But I'm open to discussion. Can you think of a compelling case where Silverlight adds significant value and works with MVC, but where Web Forms doesn't make sense?
  30. 3/25/2009 9:00 PM | # re: Integrating Silverlight and ASP.NET MVC
    John -- all great points...especially the peanut butter and bananas :-). I think like any other offering, there is no one "right" solution (since "right" is in the eye of the architect/developer/application at the moment). The great thing is we have choices. Is Silverlight+ASPNET MVC the right one? Not for all cases no. Heck, Silverlight isn't the right choice for all cases as well :-). I think WebForms--really HTML--is more of a natural host for Silverlight sure...but I don't think that precludes anyone from benefiting from their MVC infrastructure and using Silverlight as the UI. Heck, I imagine some will use MVC framework for a quick REST API implementation only...I know MVC purists cringe when I'd say that...but I think it will be true.
  31. 3/26/2009 10:39 AM | # re: Integrating Silverlight and ASP.NET MVC
    Tim,

    I definitely favor giving developers options, but let's be careful with what we're suggesting. Engineering best practices should guide our decisions more than what features that the latest and greatest technology provides.

    If we're talking pure (or close to it) presentation, such as borders, shading, placement, etc. then Silverlight is just a sexier HTML. But Silverlight is a very powerful technology and is a lot more than just pure presentation. In raw XAML, you can create innovative animations through declarative markup. That's what I find interesting about Silverlight -- the power to create compelling user interactions. But those interactions have a price: state. MVC has an underlying assumption that the state of the view can be determined by inspecting the model. Once you start adding the custom behaviors to your XAML, I would argue the MVC pattern no longer makes sense, but other patterns, such as MVP, do begin to make sense.

    I'm not an expert on RIA patterns, so I'll stop here, but Dino Esposito has written some recently about the MVP pattern and there's also the irreplaceable source for patterns, Martin Fowler.
  32. 3/26/2009 11:16 AM | # re: Integrating Silverlight and ASP.NET MVC
    John -- agreed, MVP/MVVM are the preferred patterns for Silverlight/WPF development. These are the patterns exposed in the Prism 2 guidance as well as by many others.
  33. 4/25/2009 7:25 AM | # re: Integrating Silverlight and ASP.NET MVC
    I think it's great to talk about the "Purist" or "Pure" implementation. The problem is, there is no such thing. People always start conversations with, "A purist would do this...", and then proceed to explain how they actually did it. These are simply guidelines to help you accomplish an end goal. As long as what you're doing accomplishes the end goal, who cares if it was a "Pure" MVC or "Pure" MVVM, etc.

    I personally love the MVC framework, even though the pattern itself was deprecated a long time ago for the MVP, which was the split into two other patterns. The point is, Martin Fowler saw that these patterns were flawed. So basically, you're going to have to do what you have to do. And have fun doing it.
  34. 4/25/2009 3:33 PM | # re: Integrating Silverlight and ASP.NET MVC
    Johnny, I'm with you...a pragmatic approach. Just make sure that whatever that approach is it is maintainable for the next person to come along, right ?! :-)
  35. 4/27/2009 5:15 AM | # re: Integrating Silverlight and ASP.NET MVC
    Tim,

    I took your idea and expanded it to have data sending and receiving with MVC + JSON:
    jarrettatwork.blogspot.com/.../...es-with-mvc.html
  36. 4/30/2009 5:46 AM | # re: Integrating Silverlight and ASP.NET MVC
    I have downloaded sample (SilverlightWithMvc.zip) and started it but SL control does not show on the MVC view. Help me correctly show Silverlight application on the ASP.NET MVC view (for ezample on the Views\Home\Index.aspx).
  37. 4/30/2009 7:39 AM | # re: Integrating Silverlight and ASP.NET MVC
    VOBA -- in my sample I used a different view -- it isn't on the home page but a product page -- look there.
  38. 4/30/2009 12:06 PM | # re: Integrating Silverlight and ASP.NET MVC
    OK, but it does not showa any Silverlight list boxes at the product page, why? I have installed SL 2 GDR 1 (2.0.40115.0) and ASP.NET MVC 1.0. Could some one help me to post any SL control on some MVC view? To show SL control on the .aspx page (ASP.NET Web Pages) I have used this:

    <%@ Register Assembly="System.Web.Silverlight" namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

    <div>
    <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/SilverlightApp.xap"
    MinimumVersion="2.0.30923.0" Width="100%" Height="831" Windowless="true"/>
    </div>

    and everything was OK!

    Which script I have to use to post SL control in the ASP.NET MVC view?

  39. 4/30/2009 12:46 PM | # re: Integrating Silverlight and ASP.NET MVC
    VOBA perhaps you don't have SQL Server running? This app uses a SQL database so you'll need to have it running for the data to appear.
  40. 5/6/2009 12:43 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi !

    Sad, I think, nr. X. Sad, because more and more samples I try, they will not work. Even this one. I am new to the stuff and see no change to find the reason out. I see no data. Just to be sure, I was correctly adapting the given connection string to my sql2005dev edition, I just downloaded and installed the express edition. No changes:No data.

    A litte caution for newbies would really be good and save them a lot of time.

    br--mabra
  41. 5/6/2009 1:53 PM | # re: Integrating Silverlight and ASP.NET MVC
    mabra -- I could have been more clear, sorry for that. This does use SQL Server Express 2008 (also free). But all you need really is to attach the Northwind database if you don't want to use SQL2008 and make sure the model is updated to your specific connection string.
  42. 5/21/2009 12:37 AM | # re: Integrating Silverlight and ASP.NET MVC
    Regarding the problem that silverlight category view with products was not shown and which was already reported in this thread , it is actually FireFox problem. I guess , it was tried in IE , but Chrome shows SL part properly as well Unfortunately my running numerous Silverlight demos for the last several months reminded the old joke about Java : write once, test everywhere. Other general comment related to the view state which also applies to the new navigation control in SL3 is that view state is not kept out of box. User should expect when she returns to "products" tab to see what was there when she navigated out. It would interesting to know how to keep this state and restore it properly and without too much work for various user controls. E.g. imagine Silverlight TreeView expanded deeply in many places and etc... Well in pure Silverlight I may stick to ControlTab container but for your scenario or SL3 navigation control should be unified approach to keep/restore a state.
  43. 5/25/2009 1:26 AM | # Web Design Company
    While integrating Silverlight into my MVC application I encountered a problem where the Silverlight dlls are not copied to the bin directory of my MVC application. Do I have to do something special to get these dlls copied?
  44. 5/25/2009 7:52 AM | # re: Integrating Silverlight and ASP.NET MVC
    Shahid -- the would get copied to a different directory depending on your project linking (ClientBin by default).
  45. 6/9/2009 11:52 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi !

    Sad:Just another not working silverlight example. This all - after month of studying and download samples:99% does even not work. Where to the hell is the development on this planet? In the kindergardden??????????

    sorry--mabra
  46. 6/22/2009 9:11 AM | # re: Integrating Silverlight and ASP.NET MVC
    Nice article. For what's said about Microsoft, as a coder I love to see this sort of stuff in action and love the stuff that's coming out of Redmond at the moment.
  47. 6/23/2009 1:01 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hello, I'm new to Silverlight & MVC. I'm planning to use Silverlight for a web project.I would like your opinion. Should I use Silverlight with asynchronous post backs, or should I use Silverlight with the MVC extensions as you've provided in your example?Any feedback/opinions greatly appreciated.
  48. 6/30/2009 11:23 AM | # re: Integrating Silverlight and ASP.NET MVC
    First of all thanks to you Tim and all those other people who have contributed their nice ideas.

    I tried your application. I did read through the reviews.

    I also feel (like John) we may be overloading too many concepts in to a project just to be able to add it to our resume !!! ;). But on a different note I think if we use silverlight user controls for screens and are hosted with MVC it might be nice. I see that your usercontrol is linked to the test page rather than to the appropriate pages. I also see that applications might evolve and we might not actually use a round trip concept for all the pages but for only specific pages (a set of functionality). It also raises another interesting question on how many actions/discrete set of functionality do we have in our application to be able to justify the usage of MVC. I saw others response and samples. But it might need very high maintenance and skilled people to be able to build those sort of request /response and data contract oriented stuff.

    Please add any architectural changes related to MVC and silverlight periodically.

    Thanks once again
  49. Gravatar
    7/2/2009 9:47 AM | # re: Integrating Silverlight and ASP.NET MVC
    Silverlight 2 RTW has been out for a couple of weeks now and it is already being compared to ASP.NET MVC which is an evolutionary way to design web applications using ASP.NET. I read a concise summary (pros and cons) of ASP.NET MVC from Jason Young. His article can be read here: www.ytechie.com/.../aspnet-mvc-pros-and-cons.html.
  50. 7/5/2009 12:38 PM | # Missing files in project
    Hi !

    Thanks for the description and your work. This looks like an interesting approach.

    Bu please help me:The files "SilverlightWithMvcTestPage.aspx" and "SilverlightWithMvcTestPage.html" are missing from the project and it does not run. Beeing new to SL, it seems to impossible to repair that. Could you possibly please update this project?

    Thanks a lot!

    br--mabra

  51. 7/6/2009 12:29 PM | # re: Integrating Silverlight and ASP.NET MVC
    mabra -- those files don't exist in this project as I'm using an MVC template and my content is in one of the Views.
  52. 7/7/2009 11:31 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi !

    Ok, thanks, I have now registered, that this is an error in the projectfile and I ignored this. But starting the right file and going to 'product's only gives me an silverlight error:

    Error: Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
    at System.Net.OpenReadCompletedEventArgs.get_Result()
    at SilverlightWithMvc.Page.mvc_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)
    at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
    at System.Net.WebClient.OpenReadOperationCompleted(Object arg)

    Can you please give me a hint?? The SqlExpress is running well.

    Thanks--mabra
  53. 7/13/2009 5:14 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi!
    When I try running your project in ie8, it's work fine.
    But in FireFox 3.5 Silverlight object not visible.
    Why?
    Thanks
  54. 7/15/2009 8:03 PM | # re: Integrating Silverlight and ASP.NET MVC
    I think it's a great solution. Why try and craft the perfect implementation when you can just go with what works? So what it breaks a few rules!! They were meant to be broken. At the end of the day you're using your favorite framework, you client is happy, and life goes on.
  55. 7/25/2009 3:20 PM | # re: Integrating Silverlight and ASP.NET MVC
    Thank you for your great Post, I was looking for this combination MVC and Silverlight. Silverlight RIA just impressive and MVC is TDD oriented which I really fond of. Moreover combine them through JSON oh... very2 nice. a whole day trying to combine them and finally found the ready solution from your blog.
  56. 7/26/2009 1:21 PM | # re: Integrating Silverlight and ASP.NET MVC
    I wonder how to integrate silverlight better, because MVC uses a lot of ajax and json. which pattern is better, whether to use javascript to manipulate silverlight as a control object (DLR approach) or the approach presented in this blog. at present I see the first approach seems to be more attractive because we can manipulate silverlight but also all DOM object, json comm is very easy with jquery or even there is also built-in ajax helper for it. is there any cons for it ?,
  57. 8/5/2009 5:54 AM | # 
    Hi,
    So how would you go about posting the data back to the Server? You could send back the data Form Encoded. I don't think that the asp.net mvc DefaultModelBinder doesn't support deserializing json.
  58. 8/6/2009 2:20 PM | # re: Integrating Silverlight and ASP.NET MVC
    I really fond of. Moreover combine them through JSON oh... very2 nice. at present I see the first approach seems to be more attractive because we can manipulate silverlight but also all DOM object, json comm is very easy with jquery
  59. 8/12/2009 5:24 PM | # re: Integrating Silverlight and ASP.NET MVC
    Tim,
    In your case you have only one silverlight page(page.xaml) which corresponds to index.aspx.
    In your index.aspx, you call the xap as:
    <param name="source" value="ClientBin/SilverlightWithMvc.xap" /> and the Application_Startup creates an instance of page.xaml.

    What if you had more than one page( say page2.xaml, page3.xaml) which are called from within other views say index2.aspx, index3.aspx, respectively. Would you again have xap in the object tag of these aspx pages. If yes, this would call Application_Startup everytime user moves from index.aspx to index1.aspx, index2.aspx, etc and vice-versa. Also, how would Application_Startup know which xaml class to instantiate depending on the view of the MVC application which is calling it?
    I am working on an application using a similar model and am at a loss as to how to proceed.
    Regards,
    Sandeep
  60. 8/17/2009 5:23 AM | # thanks
    Thanks for this nice info, it's so useful for me.
  61. 8/17/2009 4:22 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim(or any other Guru),
    Can anyone please reply to my question above?

    Sandeep
  62. 8/18/2009 2:52 PM | # re: Integrating Silverlight and ASP.NET MVC
    Sandeep - it seems like you are wanting to correlate a XAML page with an MVC page...I'm not sure why you want to do that.
  63. 8/22/2009 6:38 PM | # re: Integrating Silverlight and ASP.NET MVC
    Nice post Tim. This one really got me thinking. I started replying, but it got long, so I made a post out of it myself. jeffdeville.com/.../...ul-principles-and-RIAs.aspx Would be interested to here what you think. In the meantime, I may have to go check out Prism... :-)
  64. 8/26/2009 7:53 AM | # re: Integrating Silverlight and ASP.NET MVC
    Great article Tim. Thanks for the information.
  65. 8/26/2009 8:03 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim

    I have just started studying Silverlight.
    I am looking for way how to bind Silverlight into MVC pattern as Views

    Wow, here I find it.
    Unforunately I have some problems with your sample because
    I am using SQL Server 2005. Could you give me some advices?
    My problem is as follows:
    public ActionResult List()
    ...
    return Json(cats);

    OK, cats contains data,
    but I cannot see the list objects on the webpage.
    Has anyone got an idea?

    Another question is:
    Why JSON/LINQ? How about XML?
    Maybe I will get the answer for the question above when the sample runs.

    Thanks for your help
    Chrs
    CholonKid
  66. 8/27/2009 4:39 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim

    now I found out.
    The diff : u must use the IE 8.0
    Within Firefox it won't show the result.

    What should we do, so that it is not depend on browsers?

    Chrs
    Cholonkid
  67. 8/27/2009 8:32 AM | # re: Integrating Silverlight and ASP.NET MVC
    CholonKid - I suspect it has something to do with how your container for the app is built (FF requires explicit sizing on certain elements)
  68. 8/29/2009 12:46 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim

    thanks for your reply. I c the diff now.
    BTW - I would like follow the opinion of Sandeep.
    Could you only bind 1 xap ClientBin and 1 Page.xaml to one MVC apps?
    It is not the correlation.
    I think it is the context of each site.
    i.e : I plan the build a webshop. then I will have many xaml and different functinal page.
    Certainly I can build all in one Silverlight project and compile it to one xap file.
    But I want to avoid a huge xap file.

    What do you think? Have you got already some approach to this topic?

    Chrs
    Cholonkid
  69. Gravatar
    9/4/2009 12:28 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim, this might be related to what Sandeep was asking about.
    In your example it looks like the code behind of the silverlight view calls the controller and then handles the conversion of the results.

    But I am wondering as to where you would put logic for opening another view. Would that be in the same code behind of the main page? I am assuming we could have more than one page here...

    Once the silverlight control is up, asp.net mvc framework is not longer taking care of the navigation among different views, from what I see.

    Thank you.
  70. 9/10/2009 1:05 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim, I would also be interested in the solution of a real application scenario with more pages.

    Regards!
  71. Gravatar
    9/15/2009 11:27 AM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks for the first take on what I am sure will be a popular design pattern. I am going to create an application for a client using some of these techniques. Maybe I can improve on what you have started.

    Emo
  72. 9/19/2009 6:34 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hi, could you clarify the relations between RIA services and this approach on the client: aren't Domain Service extension a way to automate the creation of the client code for the data model (i.e. the category class in the example complete with CRUD methods?) if so can we expect to use this RIA services once the pass the preview stage?
  73. 9/19/2009 10:11 AM | # nice
    Yeah, thanks for that, but actually I still need more than this. I am waiting for the other post.
  74. 10/12/2009 2:55 AM | # re: Integrating Silverlight and ASP.NET MVC
    This is great to get an insider view on how to do this process. Thanks for sharing your experience and knowledge.This is easy to follow and seems to work perfectly well for those who need it. Silverlight is excellent and becoming very popular so anything to do with making the use of t more widespread and tailored is a good thing. The varying opinions in the comments have also been great. I've learned a heap more just from reading those and following some good links to good information.
  75. 10/14/2009 10:04 PM | # re: Integrating Silverlight and ASP.NET MVC
    Good post but not cool sufficient to rule. I usually never comment on posts, and yet I can't help leaving a comment: people never learn, they will constantly ignore you! But Amazing work... gorgeous
  76. 10/22/2009 9:14 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim! Great example there. We seemed to have same thing in mind. The problem now is that I want to get datas from MySQL database for our project(note that MySQL CANT be switched to anything else). We already made it work 100% with MVC c# creating our own custom Repository and classes. Also we have many stored proc to retreive/save. Now the point is... can it be possible to stuffs in the XAML code like we do in the HTML code...
    example :

    <% foreach (var item in Model) { %>

    Team # :

    <%= Html.Encode(item.id_team) %>

    name :

    <%= Html.Encode(item.name) %>
    <br />
    <% } %>

    we can all agree with one thing : this is perfectly extracting datas and showing them on screen. But what if I wanted to do this in a SL page... like in:

    <navigation:Page x:Class="Maple2.About" xmlns="schemas.microsoft.com/.../presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="schemas.microsoft.com/expression/blend/2008" xmlns:mc="schemas.openxmlformats.org/.../2006" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" Title="Team" Style="{StaticResource PageStyle}">

    <Grid x:Name="LayoutRoot">
    <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">

    <StackPanel x:Name="ContentStackPanel">

    <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="Team"/>
    <TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}" Text="Content in team"/>

    </StackPanel>

    </ScrollViewer>
    </Grid>

    </navigation:Page>


    If there's a way... well I didn't get lucky finding it because I've been looking on the web whole last 2 days. If anyone can help that'd be awesome help for our whole team. SL is AN OPTION and a challenge for us. But we still want to do it...AJAX is our next and only option left.

    Thx

    Steven
  77. 10/22/2009 10:24 PM | # re: Integrating Silverlight and ASP.NET MVC
    Steven -- is your fundamental struggle getting the data out of MySQL? Do you have a web service that exposes the data? That's all you need for Silverlight.
  78. 10/23/2009 3:38 AM | # re: Integrating Silverlight and ASP.NET MVC
    Ohhh so I'm on the good road because about 10 minutes later I was reading something similar saying a web service has to be created and I found how to. Thx to point me right ^^

    PS: yes, it was what makes me struggling ;P
  79. 10/26/2009 12:09 PM | # re: Integrating Silverlight and ASP.NET MVC
    Hi Tim, Steven here again! We have been working alot on getting this fitting. Sounds like the webservice ain't easy thing to handle with all the messed up tutorials using SL 2 beta 2... It makes us searching for hours for stuffs that don't even exist anymore apparently(from what few members of the team said). So now I'm wondering if you'd be up to make a guide on how using MySQL database along with silverlight to write AND read the database. So far we figured out that a PHP script can read our database and put the datas in XML file. Then with LINQ to XML we could try to read this and use it in silverlight but it gets confusing for everyone (looked for hours on the web). I guess it would be same way to write in the database... silverlight -> LINQ to XML -> php -> database. The whole team would be glad if you can clarify things for us :D


    Thx

    Steven~
  80. Gravatar
    10/30/2009 5:20 AM | # re: Integrating Silverlight and ASP.NET MVC
    Silverlight seems to be a popular option for many and thanks for the explanation and the code here. Trying to get my head around some new aspects of Silverlight so I decided that would be easier if I went back through these types of articles to get a full picture of the use and capabilities of Silverlight. Silverlight is a great technology and learning more about it has been very beneficial and opened my eyes to the possibilities it holds.
  81. 11/3/2009 3:41 PM | # re: Integrating Silverlight and ASP.NET MVC
    Great post!
    Integrating Silverlight and ASP.NET is not that easy!
    And you explain the best way I´ve ever seen.
    Thanks.
  82. 11/11/2009 5:51 AM | # re: Integrating Silverlight and ASP.NET MVC
    Hey Tim,

    Thanks for this great post! Is it okay if I make a request or suggestion on how to make it better? Can you please show an update on how to do this with 1-many and/or many-many relationships? THIS is where I've seen MVC start to have problems because of the attach state. Part of the problem with a lot of the examples online right now show one aspect really well (for example: "Silverlight and MVC", or "Entity Framework and MVC", or "Table-per-concrete-type and MVC"), but don't really explain what happens when you put the pieces together. For example:

    I'm writing a request portal using:
    - MVC 1.0 as the Framework
    - Entity Framework for the data model (with 1-many relationships and table-per-concrete-type inheritance)
    - SQL 2005 as the database
    - Windows authentication (intranet only app)
    - I'm still trying to modify it so that the Silverlight 3 is swapped in as the "View" instead of ASPX pages.

    I almost have it. I had the other pieces of it working with ASPX, but switching the "View" to Silverlight 3 is harder than I thought because of the context. I don't want to give up and settle for using AJAX instead because I really want to use the Silverlight 3 web tools (like the Calendar) in my user control panels, plus it just flows nicer for the user experience.
  83. 11/15/2009 1:07 PM | # re: Integrating Silverlight and ASP.NET MVC
    I have surfed the net more than three hours today, yet I never found any interesting article like yours. It's worth enough for me. Thanks.
  84. 11/19/2009 4:14 AM | # re: Integrating Silverlight and ASP.NET MVC
    Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.
  85. 11/19/2009 4:18 AM | # re: Integrating Silverlight and ASP.NET MVC
    The level of detail you offer is really very helpful, thanks so much for this. Its really great.
  86. 11/19/2009 4:24 AM | # re: Integrating Silverlight and ASP.NET MVC
    Very thorough and helpful post and the admin is helpful for any problems.
  87. 11/19/2009 4:30 AM | # re: Integrating Silverlight and ASP.NET MVC
    this is what i am looking for. thanks!
  88. 11/20/2009 4:53 AM | # re: Integrating Silverlight and ASP.NET MVC
    Tanks for your post, i will use it in my next project!
  89. 11/20/2009 4:57 AM | # re: Integrating Silverlight and ASP.NET MVC
    i will make the same with my site, tanks for the tip.
  90. 11/30/2009 12:23 AM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks for post ..I really appreciate sharing this great post. Keep up your work.
  91. 12/4/2009 2:09 PM | # re: Integrating Silverlight and ASP.NET MVC
    I think better way to create a modularable silverlight architectura, and transfer data over wcf would be to use prism v2.
  92. 12/5/2009 10:28 PM | # re: Integrating Silverlight and ASP.NET MVC
    good information mr...thanx ^_^
  93. 12/6/2009 2:47 PM | # re: Integrating Silverlight and ASP.NET MVC
    nice information, very thanks :)
  94. 12/10/2009 4:32 PM | # re: Integrating Silverlight and ASP.NET MVC
    thanks for your tutorial!!
  95. Gravatar
    12/13/2009 2:28 PM | # re: Integrating Silverlight and ASP.NET MVC
    in Page_Loaded the Uri is hard coded.
    mvc.OpenReadAsync(new Uri("http://localhost:33828/Category/List"));

    Everything works great in VS with cassini but I cannot figure out how I can deploy this to my hosting environment.

    Any ideas would help greatly!!!
  96. 12/13/2009 4:12 PM | # re: Integrating Silverlight and ASP.NET MVC
    Jim -- you would put a URI that reflects the controller you are calling -- or build up a relative one.
  97. 12/21/2009 11:03 PM | # re: Integrating Silverlight and ASP.NET MVC
    The main advantage of a twin mattress set for sale is the size. A twin mattress is small enough to fit in just about any size room without taking over the entire room. Spare bedrooms usually aren’t large enough to accommodate large beds in addition to furniture, but a cheap twin mattress set is often the perfect fit.
  98. 12/24/2009 12:23 PM | # re: Integrating Silverlight and ASP.NET MVC
    I really appreciate sharing this great post. Keep up your work.
  99. Gravatar
    12/30/2009 11:04 AM | # Rigth direction
    Actually you are going in right direction, and it is necessary for all us to follow you.
  100. 1/6/2010 8:25 AM | # re: Integrating Silverlight and ASP.NET MVC
    thanks mister
  101. 1/8/2010 2:31 PM | # re: Integrating Silverlight and ASP.NET MVC
    Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which we all need, thanks for all the enthusiasm to offer such helpful information here.


  102. 1/11/2010 10:07 AM | # re: Integrating Silverlight and ASP.NET MVC
    The web site and blog of Tim Heuer, Program Manager for Microsoft Silverlight. A great resource for learning Silverlight development
  103. 1/16/2010 8:18 AM | # re: Integrating Silverlight and ASP.NET MVC
    this is very informative
  104. 1/18/2010 9:55 AM | # re: Integrating Silverlight and ASP.NET MVC
    Excellent post a unique source to learn about silver light development please keep it up Tim Heuer.
  105. 1/19/2010 7:37 AM | # nice
    Thank you for posting such a useful website. Your weblog happens to be not just informative but also very stimulating too. There are a limited number of people who are capable of write technical articles that creatively. we are on the lookout for information regarding this topic. We ourselves went through several websites to find knowledge with regard to this.I will keep coming back !!
  106. 1/22/2010 10:39 AM | # re: Integrating Silverlight and ASP.NET MVC
    Excellent post, Very informative as well. I have learn more than enough from this post,please keep it up.Thanks for sharing
  107. 1/29/2010 8:00 AM | # re: Integrating Silverlight and ASP.NET MVC
    A twin mattress is small enough to fit in just about any size room without taking over the entire room. Spare bedrooms usually aren’t large enough to accommodate large beds in addition to furniture
  108. 2/1/2010 5:11 PM | # re: Integrating Silverlight and ASP.NET MVC
    agencia de web design, criação e otimização de sites...
    Excellent post, this is very informative, tanks
  109. 2/3/2010 11:45 AM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks for the code snippets, they solved a different problem but thanks.
  110. 2/3/2010 1:44 PM | # re: Integrating Silverlight and ASP.NET MVC
    Thanks for the post. Can you give me a tiny example of how I would post data from a Silverlight Client to a ASP.NET MVC backend? I've been scratching my head over it. Just a little something to get me started would help.
  111. 2/3/2010 10:58 PM | # re: Integrating Silverlight and ASP.NET MVC
    love this article, so much depth and content.
  112. 2/5/2010 10:10 AM | # re: Integrating Silverlight and ASP.NET MVC
    This will help me to integrate silverlight to my new homepage, exactly what I was looking for. thx.
  113. 2/16/2010 10:30 PM | # re: Integrating Silverlight and ASP.NET MVC
    great post. i enjoy reading your blog. very informative. thanks
  114. 2/17/2010 10:15 AM | # re: Integrating Silverlight and ASP.NET MVC
    Great I like it
  115. 2/21/2010 4:54 AM | # re: Integrating Silverlight and ASP.NET MVC
    thanks for your post. it provides me some new knowledge about silverlight.
  116. 2/22/2010 11:53 AM | # re: Integrating Silverlight and ASP.NET MVC
    If you want to migrate this solution to VS 2010 beta 2 (or higher), make sure that you change lines 28 and 41 of CategoryController.cs, otherwise you will get an exception. Line 28 should read:
    return Json(cats, JsonRequestBehavior.AllowGet);
    (note the added second argument). Same for line 41.
  117. 2/22/2010 8:04 PM | # re: Integrating Silverlight and ASP.NET MVC
    This post help me to integrate silverlight to my new homepage, exactly what I was looking for. thanks
  118. 2/28/2010 11:17 AM | # re: Integrating Silverlight and ASP.NET MVC
    John -- agreed, MVP/MVVM are the preferred patterns for Silverlight/WPF development. These are the patterns exposed in the Prism 2 guidance as well as by many others.
  119. 3/6/2010 8:49 AM | # re: Integrating Silverlight and ASP.NET MVC
    Yeah, thanks for that, but actually I still need more than this. I am waiting for the other post.
  120. 3/8/2010 7:19 PM | # re: Integrating Silverlight and ASP.NET MVC
    this is great stuff on slant fin humidifier. Kill germs and ultraviolet light. Best humidifier ever!
  121. 3/17/2010 2:38 AM | # re: Integrating Silverlight and ASP.NET MVC
    HI
    I'm studying ASP.Net. This is i needed it. Because its one of the question of exam of my class.
    Thanks for this useful information friend.
  122. 3/19/2010 12:14 AM | # re: Integrating Silverlight and ASP.NET MVC
    This post help me to integrate silverlight to my homepage, I tried this, but i've some problem, i'll rectify that error early. thanks

 
Please add 5 and 2 and type the answer here:
First time here? You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting! (hide this)