ASP.NET MVC Framework

One of the things that many people have asked for over the years with ASP.NET is built-in support for developing web applications using a model-view-controller (MVC) based architecture.

Last weekend at the Alt.NET conference in Austin I gave the first public demonstration of a new ASP.NET MVC framework that my team has been working on.  You can watch a video of my presentation about it on Scott Hanselman's blog here.

We'll be releasing a public preview of this ASP.NET MVC Framework a little later this year.  We'll then ship it as a fully supported ASP.NET feature in the first half of next year.

What is a Model View Controller (MVC) Framework?

MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers.

  • "Models" in a MVC based application are the components of the application that are responsible for maintaining state.  Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL).
  • "Views" in a MVC based application are the components responsible for displaying the application's user interface.  Typically this UI is created off of the model data (for example: we might create an Product "Edit" view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object).
  • "Controllers" in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI.  In a MVC application the view is only about displaying information - it is the controller that handles and responds to user input and interaction.

One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application.  Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.

The MVC pattern can also help enable red/green test driven development (TDD) - where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself.

A few quick details about the ASP.NET MVC Framework

I'll be doing some in-depth tutorial posts about the new ASP.NET MVC framework in a few weeks once the bits are available for download (in the meantime the best way to learn more is to watch the video of my Alt.net presentation).

A few quick details to share in the meantime about the ASP.NET MVC framework:

  • It enables clean separation of concerns, testability, and TDD by default.  All core contracts within the MVC framework are interface based and easily mockable (it includes interface based IHttpRequest/IHttpResponse intrinsics).  You can unit test the application without having to run the Controllers within an ASP.NET process (making unit testing fast).  You can use any unit testing framework you want to-do this testing (including NUnit, MBUnit, MS Test, etc).
  • It is highly extensible and pluggable.  Everything in the MVC framework is designed so that it can be easily replaced/customized (for example: you can optionally plug-in your own view engine, routing policy, parameter serialization, etc).  It also supports using existing dependency injection and IOC container models (Windsor, Spring.Net, NHibernate, etc).
  • It includes a very powerful URL mapping component that enables you to build applications with clean URLs.  URLs do not need to have extensions within them, and are designed to easily support SEO and REST-friendly naming patterns.  For example, I could easily map the /products/edit/4 URL to the "Edit" action of the ProductsController class in my project above, or map the /Blogs/scottgu/10-10-2007/SomeTopic/ URL to a "DisplayPost" action of a BlogEngineController class.
  • The MVC framework supports using the existing ASP.NET .ASPX, .ASCX, and .Master markup files as "view templates" (meaning you can easily use existing ASP.NET features like nested master pages, <%= %> snippets, declarative server controls, templates, data-binding, localization, etc).  It does not, however, use the existing post-back model for interactions back to the server.  Instead, you'll route all end-user interactions to a Controller class instead - which helps ensure clean separation of concerns and testability (it also means no viewstate or page lifecycle with MVC based views).
  • The ASP.NET MVC framework fully supports existing ASP.NET features like forms/windows authentication, URL authorization, membership/roles, output and data caching, session/profile state management, health monitoring, configuration system, the provider architecture, etc.

Summary

If you are looking to build your web applications using a MVC approach, I think you'll find this new ASP.NET MVC Framework option very clean and easy to use.  It will enable you to easily maintain separation of concerns in your applications, as well as facilitate clean testing and TDD. 

I'll post more tutorials in the weeks ahead on how the new MVC features work, as well as how you can take advantage of them.

Hope this helps,

Scott

139 Comments

  • It sounds great. Hardly wait for a public preview!

  • So you can use the existing ASPX,ASCX... views with declarative server controls, but if the server controls need viewstate and page lifecycle to work, what's the effect of having server controls in MVC based views ?

    Thanks

  • It looks great. It should make it a whole lot easier to write good code.

  • Hi Scott,
    Will MVC Framework be include in VS 2008 RTM?

  • I know ViewState has um, "issues", but on the other hand it does address a very real problem. I remember the joy [assume irony there] of redisplaying pages on error in Perl and classic ASP...and the absolute *bliss* of writing the code to re-establish position in selection lists for example. Oh yeay. Tedious and fiddly and distracting from the real task.
    If we use the MVP framework will it be back to square one for this sort of thing, or will some appropriate goodness be provided for those of us who think life's too short for all that? I don't want to go back to rebuilding the taps every time I have a shower. Metaphorically speaking.

  • Hi Dan,

    >>>>>> So you can use the existing ASPX,ASCX... views with declarative server controls, but if the server controls need viewstate and page lifecycle to work, what's the effect of having server controls in MVC based views ?

    The views themselves are standard .aspx, .ascx, .master files - so there is still a code-behind class, and you can handle rendering events off of controls to cleanly separate view markup from view rendering logic.

    In terms of declarative controls, the control model is the same for building controls - the difference is just that you can't use the postback feature. Logically this is like building a .aspx page today that doesn't have a control on it. So controls like and other controls work just fine - you'd just use a standard form post or url for post operations.

    We'll also then have a set of MVC aware server controls that you can also use in these postback-less view pages. They'll integrate cleanly with controller based logic.

    Hope this helps,

    Scott

  • Hi NGoc,

    >>>>> Will MVC Framework be include in VS 2008 RTM?

    The MVC Framework will work with VS 2008 RTM (we'll be releasing the first preview release of it at the same time as VS 2008 RTM). The MVC framework itself will live in a separate assembly to begin with, and then be built-in to .NET 3.5 SP1.

    Hope this helps,

    Scott

  • Hi Kevin,

    >>>>>> If we use the MVC framework will it be back to square one for this sort of thing, or will some appropriate goodness be provided for those of us who think life's too short for all that? I don't want to go back to rebuilding the taps every time I have a shower. Metaphorically speaking.

    Note that the MVC framework doesn't replace the existing Web Forms model - that will obviously continue to be fully supported and enhanced. So if you prefer the control postback interaction I'd probably recommend staying with that, and use a MVP based model for testability.

    The MVC model does give you more control over the HTML that is rendered. As you noted above, this is both a good and bad thing (good in that you have more control, bad in that with more control you also need to take care of more things). We do provide a nice way to handle errors and maintain form state, so you don't have to write ugly code to handle that. The server control model also provides a clean way to encapsulate view-helper functionality in a nice way for your UI, and there will be a rich set of controls built-up to help with this.

    Hope this helps,

    Scott

  • Thank you Scott, one question:
    One nice thing about the Brail view engine is that the views are compiled independently of the main application, so if you make changes to a view it gets recompiled instantly.
    I suppose the DLR based views are not compiled, but in the case of the aspx views, will a change in the view require a reload of the application with a potentially long delay, it would be nice if not.

  • Hi J Philip,

    >>>>>>> One nice thing about the Brail view engine is that the views are compiled independently of the main application, so if you make changes to a view it gets recompiled instantly. I suppose the DLR based views are not compiled, but in the case of the aspx views, will a change in the view require a reload of the application with a potentially long delay, it would be nice if not.

    When .aspx pages are changed ASP.NET detects the change and automatically creates a new assembly for it. That way we don't need to restart the application. In the case of DLR based .aspx pages we actually don't ever even create an assembly - instead we can compile them in-memory (that is how IronPython based .aspx pages work).

    Note that because the ASP.NET MVC framework is pluggable, you can optionally use a MonoRail Brail View engine for rendering your views with it. So if you like the Brail model that will continue to work with the new MVC framework as well.

    Hope this helps,

    Scott

  • @Dan Scott says in the demo that you can instruct controls looking for the form to render anyway. But he also says that there will be a slew of server-side controls specific to the MVC framework. The controls will have the page life-cycle, sans post-back.
    @Kevin Part of the problem with non-MVC Perl and classic ASP was that you rarely ever had a model to encapsulate your validation rules. With .NET it is much easier (for me) to create those classes, so it will be easier to work around the issues you mentioned. &nbsp;For example, let's say you are editing product #4. Your URL would be:
    /products/4/edit
    After completing the edit, the user posts to:
    /products/4/update
    The controller takes the posted values and updates your product model. &nbsp;The product model holds your validation rules. &nbsp;If the product is valid, you save and redirect to the product detail or product listing URL. If it is not valid, you send that same model to your edit view which is responsible for showing the validation messages.
    Your concerns are now separated. &nbsp;Your model contains your validation rules, your controller checks to see if the model is valid and persists the data if necessary, and your view is responsible for showing the product information including validation messages. &nbsp;Now it is much easier to control your URLs, remove duplicate code, and test your app. This is a good thing.
    I was at the ALT.NET Conference and I had the opportunity to speak with Scott about this after his presentation. The vast majority of folks in the room (including me) were very enthusiastic about what we saw and more specifically, what we heard. I think the ASP.NET MVC framework is going to be a huge leap forward for developing ASP.NET applications while promoting a more sophisticated and maintainable programming model. Kudos!

  • Sorry, one more question:
    Will the MVC aware server controls be able to infer automatic client side validation from the model validation via CSS atributes for example ?

  • Hi J Philip,

    >>>>>> Will the MVC aware server controls be able to infer automatic client side validation from the model validation via CSS atributes for example ?

    We'll be looking to enable error handling based client-side styling and client JavaScript error validation off of models where possible. That won't be in the first preview in a few weeks - but it is something we've been looking at recently for later.

    Hope this helps,

    Scott

  • I know its called the "ASP.NET" MVC Framework but is there any scope to cater for non-web based projects, WinForms, smart-client, etc? You mention you can plugin your own view engine, but is the controller to tightly wound around IHttpRequest/IHttpResponse to allow for OOTB use in other project types?

  • I'm looking forward to it. I think there are many developers like me, who read about MVC but don't try it out until it's released by Microsoft. One reason for me is that I expect Microsoft to come up with a framework that will be no. 1 when it comes to supporting all ASP.NET features. The fact that you will release special controls to work with MVC is proof of that.
    What is the RTM date for Visual Studio 2008?

  • Hi Mike,

    >>>>> What is the RTM date for Visual Studio 2008?

    VS 2008 and .NET 3.5 will RTM later this year. Not too far off now....

    Thanks,

    Scott

  • Thanks Scott.

    You have perfectly justified my request to know more about MVC.

    Waiting for Tutorials on this.

    Will there be LINQ and Dynamic Languages Support in Future. This is also important for future....?

    Thanks Again

  • Hi Scott,

    I must have posted my blog section about MVC last night around the same time as yours. I look forward to seeing some example samples on here soon.

    With the views and controllers and regarding naming conventions, in views, will you need to have the separate sub-folders such as "Products" or "Welcome" or is this an nicer optional way of logically linking a view to a controller even though it doesn't automatically use a view?

    ChrisNTR

  • We have a fairly complex ASP.Net CMS(90,000 lines of C# code, 10,000 lines of Javascript). Do you recommend porting existing applications, or do you think the MVC framework is best suited for new projects?

    And is it possible to use a mix of the page model and the MVC framework in the same application, so we can port parts of it as we go along?

  • I am a C# junkie, but I use Django for web development because ASP.net places far too much focus on the designer. With Django, I find an artist to do the CSS file and I just make a bunch of divs in the template.
    Looks like you guys nailed it with this. Maybe I'll starting using ASP.net when this is available. Awesome stuff :-)

  • Hi Chris,

    >>>>> With the views and controllers and regarding naming conventions, in views, will you need to have the separate sub-folders such as "Products" or "Welcome" or is this an nicer optional way of logically linking a view to a controller even though it doesn't automatically use a view?

    To help with rendering a view the default Controller base class has a RenderView() method that you can call with the name of a view. For example, the below code would tell ASP.NET to render the "Edit" view - and pass in a product object as the model:

    RenderView("Edit", product);

    By default the base controller looks to find views underneath the \Views\[controllername]\ directory. So if your controller was named "ProductsController", the default view engine with the ASP.NET MVC framework work look for a \Views\Products\Edit.aspx file and if that wasn't found look for a \Views\Products\Edit.ascx file.

    You can optionally override this naming policy if you'd like - but we tried to have a model that promotes a clean naming pattern by default.

    Hope this helps,

    Scott

  • Your last LINQ blog was Part 9. Do you have more planned?

  • Hi Scott,

    Can you explain the difference between MVP and ASP.NET MVC Framework?

    Thanks,
    Oyvind

  • Have spent the weekend using Castle MonoRail to get me clued up about MVC approaches, and I'm hooked. Creating AJAX applications using MVC just feels far simpler and cleaner, where you can control exactly what goes back in an HTTP Post. I look forward to porting these test applications into the ASP.NET MVC framework.

    As one comment mentions, I would love to see samples that demonstrate client side validation (using html classes etc.) coupled with server side validation (via the hooks in LINQ), to create a very integrated approach.

  • Thanks Scott & Mike, I think I get the point. I see now that this MVC stuff is big news for WebForms lovers too. Even it could be named asp.net 4.0 :)
    For example, when building an Ajax-intensive application is very important to send light requests to the server so the app is interactive and responsive, and viewstate is a problem here.
    But with this you can isolate those areas of the app with total control over the Html generated so you get nice semantic markup with clear javascript ( without references to INamingContainer-generated IDs ) and several light forms in the same view.

    And if you want to unit test the processing of an existing WebForm, you can 'convert' it to MVC model so the form element in the generated Html now points to a Controller class that you can unit test without loading asp.net engine thanks to IHttpRequest,IHttpContext... mocks.

    The idea is very nice indeed, I have curiosity for the implementation details ( probably with SetRenderMethodDelegate to substitute the calls to _doPostBack or something similar ) but I can wait to the CTP :)

    I see hordes of php/java developers being suddenly interested in asp.net, and many web 2.0 sites are going to born using the powerful .net framework in the server side. Damn, I'm excited

  • Thanks Scott,

    Great Things coming up now from your team.

    Can you be more specific about DLR, Dynamic Languages, LINQ and Asp.Net futures support on MVC.

    Thanks

  • Hi Scott,

    this is great news, I'm looking forward for the first CTP. We are currently using a home-grown MVC framework which was developed with .NET 1.1 and obviously needs some rework, so this announcement comes just in time.

    Could you already give some more info on the MVC-specific web controls you are planning to release?

    Regards, Robert

  • Thanks scott,
    :)

  • How will ctrl-f5 or view in browser work in Visual Studio? I thought about this while watching the movie. You have to type in the action in the url to test an action.

  • Scott, one question: how will UpdatePanel and other ajax-related features, that rely on postback model, be supported?

  • Hi,

    I've felt in love with an asp.net because of the wonderful server controls that keep their state and do lot of things in the background for me so that I don't have to do it (especially in asp.net 2.0). But when I have 'discovered' TDD I've learned that asp.net and TDD don't play well.

    Now I'm enthusiastic about ASP.NET MVC framework (the only reason that I didn't spend more time with monorail is the fact that I was afraid that it will be abandoned someday, like lot of other OS projects) but have a few concerns:
    - view code in your presentation video looks dangerously like an old asp (without .net). The same is valid for monorail nvelocity too. I hope you bring the best of the two worlds together
    - you claim that integration of the existing asp.net features will be smooth and easy (profiling, membership and roles, localisation), but first I would like to see an evidence of that.

    Anyway, keep up the good work.

  • How does this fit in with Microsoft P&P's WCSF or the older UIP? I thought Microsoft was already providing guidance/code for using the MVC methodology. It seems like "yet another" alternative to me.

  • Hopefully we can get the good things (URL-rewriting) without the bad things (modell view controller bloat, automated testing)! Will it be possible to take these parts, that are difficult to implement at the moment?

    Just look at urlrewrite.net: It uses the most error prone thing in the world: Regular expressions and it has to do much work that change the way how postback works so that these webform-pages can acutally be rewritten.

  • How does this effect the Web Client Software Factory? Are the two intended to be used together? Is this going to replace the View with Presenter recipe? What about the Page Flow stuff?

  • I'm very excited to start using this. I've tried MonoRail and have also been using Ruby on Rails and have been completely spoiled. I'm curious; how much of the internals did you need to change in order to get declarative server controls working without the postback model? Will ASP.NET MVC support using existing server controls in a page without a tag? Also, will we be able to have multiple HTML forms in one page (working properly)?

    Thanks for all the great work so far!

    -Joe

  • Awesome! It can't come out soon enough.

  • Can you give us a quick example of how you post updates to a record?

    Someone mentioned post updates to "/product/4/update", but how would that actually work?

    I don't see any way to add post variables to an HttpResponse object.

  • I'm very excited about this. I've always said that I love .Net but hate ASP.Net, and they now needn't go hand-in-hand.

  • Thanks, Very good information about MVC and that too in detail. I think I'll have tobe a regular visitor of this blog.

  • Hi Kiran,

    >>>>>>> Your last LINQ blog was Part 9. Do you have more planned?

    I haven't finished the series yet - I've still got 4 more to go. :-) I'll hopefully do the next one in the next week.

    Thanks,

    Scott

  • Hi IronRuby,

    >>>>>>> Can you be more specific about DLR, Dynamic Languages, LINQ and Asp.Net futures support on MVC.

    LINQ is definitely fully supported with the MVC framework. We'll also be adding DLR support for it, which will enable you to build both views and controllers using dynamic languages (including ironpython and ironruby).

    Hope this helps,

    Scott

  • Hi Mike,

    >>>>>> How will ctrl-f5 or view in browser work in Visual Studio? I thought about this while watching the movie. You have to type in the action in the url to test an action.

    VS allows you to customize the "run" behavior in a couple of ways. One is to run the current page you are editing (which is the default). Alternatively, you can run a specific URL.

    Because in a MVC model you go to controllers first (and not directly to a .aspx file), the default project template will be configured to load the "/" URL by default when you press F5/Ctrl-F5. If you want you can customize this further to go to a specific URL (just pull up the properties in the IDE and change it).

    Hope this helps,

    Scott

  • Hi Alexander,

    >>>>> Scott, one question: how will UpdatePanel and other ajax-related features, that rely on postback model, be supported?

    UpdatePanel does use postback, so you won't use that control directly within a MVC based view. But there will be a control (and optional helper method) with capabilities very similar to it. It will invoke an action on a controller and allow you to incrementally update a portion of HTML really easily. It will enable you to use the ASP.NET AJAX libraries really easily. I'll blog more about this in the weeks ahead.

    Hope this helps,

    Scott

  • Hi Inisom,

    >>>>>>>> - view code in your presentation video looks dangerously like an old asp (without .net). The same is valid for monorail nvelocity too. I hope you bring the best of the two worlds together

    Some people prefer the model, and the audience at alt.net that I was showing the MVC model to wanted me to use that approach (which was why I did). I could have alternatively used a instead for doing the listing (and data-bound it via the code-behind). This enables you to more cleanly structure your view rendering code.

    >>>>>>>> you claim that integration of the existing asp.net features will be smooth and easy (profiling, membership and roles, localisation), but first I would like to see an evidence of that.

    Yes - we will have clean integration of these. We'll have samples that show how all of these work.

    Hope this helps,

    Scott

  • Hi Christian,

    >>>>>> Hopefully we can get the good things (URL-rewriting) without the bad things (modell view controller bloat, automated testing)! Will it be possible to take these parts, that are difficult to implement at the moment?

    We are going to enable you to use the URL rewriting features with all types of pages in the future - both Web Forms as well as MVC based ones.

    Hope this helps,

    Scott

  • Hi Joe F,

    >>>>>>> I'm curious; how much of the internals did you need to change in order to get declarative server controls working without the postback model? Will ASP.NET MVC support using existing server controls in a page without a tag? Also, will we be able to have multiple HTML forms in one page (working properly)?

    We actually didn't have to change the internals to support the MVC work - ASP.NET actually already has most of the hooks necessary.

    The ASP.NET MVC framework will enable you to have multiple HTML forms on a page. Exsting controls like and others that support read-only modes work fine today with it. Postback heavy controls won't support postback operations though.

    Hope this helps,

    Scott

  • I see that your MVC framework will support NHibernate. How about support for LINQ to SQL and/or the Entity Framework/EDM?

    --rj

  • I noticed in your demo from ALT.NET you were sending anonymous types from the controller to the view in the form of a new {"value", "value2"} construct. I was under the impression that anonymous types cannot be passed outside the scope of a method. Could you explain?

  • Hi Roger,

    >>>>>> I see that your MVC framework will support NHibernate. How about support for LINQ to SQL and/or the Entity Framework/EDM?

    The ASP.NET MVC framework will work with any data provider. LINQ to SQL and LINQ to Entities are both definitely fully supported (my sample at the alt.net conference was actually done with LINQ to SQL).

    Hope this helps,

    Scott

  • Hi Josh,

    >>>>>>> I noticed in your demo from ALT.NET you were sending anonymous types from the controller to the view in the form of a new {"value", "value2"} construct. I was under the impression that anonymous types cannot be passed outside the scope of a method. Could you explain?

    Anonymous types can be passed outside of their scope - but the type name won't be known (for example: you could pass/return them as type Object and have them work).

    The helper methods I was using take an "object" as an optional parameter type and then use either IDictionary or reflection to retrieve the name/value pairs. That is how I was able to write:



    Hope this helps,

    Scott

  • Will client side helpers (javascript) built into the MVC framework use the Microsoft AJAX Library?

  • Hey Scott,

    Watched your video a few days ago (linked from Scott Ha's Blog) and was super impressed. ASP.Net MVC is exceptionally exciting -- I only wish I had it when I started the project I'm on now. It's great when a development team actually listens to their user community and it's people like you that continually restore my faith in Microsoft. Keep up the great work.

    Thanks,
    --Steve

  • ScottGu is a rock star ;-)

  • Awesome dude, rails like architecture on asp.net. .Net is so much better than rails (IMO), but its good to see Microsoft learn from what's out there and build on it, rather than sitting on its backside like Apple without Jobs (or Sun for that matter).

    Good luck, I'm gonna download this with an hour after it comes out!

  • Any chance of posting some of the code samples from your talk - or from the HelloWorld solution shown in the post - without waiting for the MVC framework to ship? I'm not talking about a working sample or complete code, just some snippets pasted into the text of a post. It's hard to read the code as it flashes by in Scott Hanselman's video. You could put big disclaimers that it's all subject to change, etc.

    I can't get my friends to break their NDA! ;-)

  • Hi, you said "URLs do not need to have extensions within them", does this needs IIS7 to work?
    Do we have to map every file type with aspnet_isapi.dll on IIS6?

  • Hi Scott, you wrote:

    >>>>> Because in a MVC model you go to controllers first (and not directly to a .aspx file), the default project template will be configured to load the "/" URL by default when you press F5/Ctrl-F5. If you want you can customize this further to go to a specific URL (just pull up the properties in the IDE and change it).

    Maybe if you're inside an action method, VS can look up a route that corresponds to that action and load that url? Would that be something that could be created as an add-in for VS by someone else?

  • Hi Andy,

    >>>>>>> Will client side helpers (javascript) built into the MVC framework use the Microsoft AJAX Library?

    We'll definitely have client-side AJAX helpers built into the MVC framework that makes it easy to use the Microsoft AJAX library. You aren't restricted to only using this AJAX library though - you could alternatively use any other JavaScript library you want.

    Hope this helps,

    Scott

  • Hi Jon,

    >>>>>>>> Any chance of posting some of the code samples from your talk - or from the HelloWorld solution shown in the post - without waiting for the MVC framework to ship? I'm not talking about a working sample or complete code, just some snippets pasted into the text of a post. It's hard to read the code as it flashes by in Scott Hanselman's video. You could put big disclaimers that it's all subject to change, etc.

    Sure - I'll try and put some together (feel free to email me directly and I can also try and shoot you a copy).

    Thanks,

    Scott

  • Hi Daniel,

    >>>>>>> imagine an eCommerce site, having the following URLs: /Products/4, /Category/3, /SearchResults/asp.net
    >>>>>>> Each of these URLs has its own controller (and only one controller), right?

    Yes - by default you'd typically architect the site to have three controllers for the above URLs - a ProductsController, a CategoryController and a SearchResultController. Alternatively, you could combine these into fewer controllers (it really depends on what functionality you want to expose).

    >>>>>>>>> Now, if I have a cart displayed on each of these sites, do I have to implement any cart action in every single controller?

    No - you'd want to have a ShoppingCart controller that you implement only once. You could then encapsulate the shopping cart UI that you embed on each page in a ShoppingCart.ascx file - which calls the ShoppingCart controller when actions are taken on it. This keeps your code clean, and ensure you only have to implement things once.

    Hope this helps,

    Scott

  • Hi Deerchao,

    >>>>>>> Hi, you said "URLs do not need to have extensions within them", does this needs IIS7 to work? Do we have to map every file type with aspnet_isapi.dll on IIS6?

    On IIS7 we can use the new URL mapping features of the web-server to handle this.

    For IIS6 you'll have two options: 1) install a ISAPI filter to enabling mapping of the MVC Urls to ASP.NET, or 2) include an extension in the URL to ensure ASP.NET is activated to process the request. We'll ship samples that show how to enable both of these options.

    Hope this helps,

    Scott

  • Hi Mike,

    >>>>>>> Maybe if you're inside an action method, VS can look up a route that corresponds to that action and load that url? Would that be something that could be created as an add-in for VS by someone else?

    You could probably create an add-in that automatically does that. That would be kinda cool. :-)

    Thanks,

    Scott

  • I would also like to know how this fits in with Web Client Software Factory.

  • How is this better than using Windows Workflow for MVC?

  • Will this address the problem where ViewState prevents multiple AJAX/callbacks from running asynchronously? Right now I experience invalidate ViewState exceptions if more than more than one request fires at a time. I would hope the new MVC model addresses this issue. However, making this all work with existing controls will be a big challenge.

  • I think this is a bad idea. ASP.NET is already MVC by nature. The Views are the pages, the controller is runtime, and model is your facade or business layer. This is just adding another layer of abstraction that provides no measurable value. People may speak of being able to test easier with harnesses, etc., but we test the code behinds the same we test any other method in a class...with the unit test framework that comes with Visual Studio. We test the rendered output with the Web Unit Testing that comes with Visual Studio. To me this is just folding to the bandwagon pressure of MVC.

    As Martin Fowler said...if it's not needed, rip it out, it's just extra moving parts that increase complexity and the cost of maintnance. (Refactoring - Speculative Generalities)

  • ScottGu: Is it possible that you could release some of the early framework code as part of an early-early release so that some of the bleeding edge people can start understanding and gearing up on it? Even the stuff you showed in the video would be good enough for me at this point. All the extra controls and AJAX-y stuff will just be extra cake when you release that part.

    The sooner we can get our hands on the basic stuff, the sooner we can start getting our developers ready for the concepts that will be coming down the pipe in the months ahead.

    Please do not wait for all the controls and AJAX stuff to be done before releasing a preview, that will be too long for some of us to get ready for it.

  • Hi Randy,

    >>>>>> I would also like to know how this fits in with Web Client Software Factory.

    The Web Client Software Factory currently uses a different approach to provide testability than this MVC option. I'm pretty sure the web client software factory will be updated in the future to also support the new MVC approach.

    Hope this helps,

    Scott

  • Hi Brennan,

    >>>>>>> Will this address the problem where ViewState prevents multiple AJAX/callbacks from running asynchronously? Right now I experience invalidate ViewState exceptions if more than more than one request fires at a time.

    Yes - this would fix that issue. Having said that, you'll still want to be careful about how you manage state when doing multiple requests - since the exact order of how they are processed is never 100% guarenteed (HTTP and browsers can send the requests in whatever order they want).

    Hope this helps,

    Scott

  • Hi Teri,

    >>>>>>> How is this better than using Windows Workflow for MVC?

    Workflow supports orchistration of actions and activities (independent of UI). This MVC framework can optionally be used with a workflow set of rules if you want to encapsulate interactions that way. Alternatively, though, you can just use standard code to define behavior.

    Hope this helps,

    Scott

  • Hello Scott,

    What's the main difference between MVC and MVP pattern?

    Thanks!

  • We hope that u have sometime for a screen cast on Channel9

  • I will download this about 4 secs after first published preview! I've been working with an enterprise app trying to get at good design, separation of concerns and UI composability all at once. things like trying to use inversion of control together with the page life cycle today are a bit tricky when your UI consists of many dynamic controls.

    MVC for ASP.NET will kill my problems I'm sure! Thanks! /M

  • Where do I get that syntax highlighting theme you use, Scott? ;-)

  • Are you planning to introduce some of the other functionality associated with Rails/Django et al.?
    - respond_to, e.g. /posts/1.xml returns us XML data? Handy for REST type applications...
    - Nested resources: e.g. /posts/1/comments
    - controller filters: e.g. before_filter :check_security

  • Hi Scott,

    Will VS2008 RTM be ready before DevConnections? How soon will MSDN subscribers receive it?

    Thanks,
    Ram

  • Hi Nateh,

    >>>>>> Would you provide some more cross-http reqeust state-management features - set of HTTP request sharing the same state, that must preserved on the server. THis is for example needed for Wizard-style pages. (example of solution instead of request and session scope we need a "process process scope": www.oracle.com/.../communicatingBetweenPages.html)

    Yes - this is something on the list that we are looking at enabling.

    >>>>>>> Is it possible to compose several controlers? Would this break the design philosphy pf MVC (think web pages with serveral Webparts, each of them contains it own controller). Motivation: encapsulation.

    Yes - we are looking at ways to enable sub-controllers so that you can better encapsulate re-usable behavior that is used across multiple pages on a site.

    Thanks,

    Scott

  • Hi Andrew,

    >>>>>>>Are you planning to introduce some of the other functionality associated with Rails/Django et al.?

    >>>>>>> - respond_to, e.g. /posts/1.xml returns us XML data? Handy for REST type applications...

    Yes.

    >>>>>>> - Nested resources: e.g. /posts/1/comments

    Yes.

    >>>>>>> - controller filters: e.g. before_filter :check_security

    Yes.

    Hope this helps,

    Scott

  • Hi Ram,

    >>>>>>>>> Will VS2008 RTM be ready before DevConnections? How soon will MSDN subscribers receive it?

    MSDN subscribers will be able to download the VS 2008 RTM as soon as it hits RTM. We'll talk more about the exact date for this soon.

    Thanks,

    Scott

  • Hi Patrick,

    >>>>>>> Where do I get that syntax highlighting theme you use, Scott? ;-)

    Send me email and I will send it to you. :-)

    Thanks,

    Scott

  • Great video, I look forward to a release but for god's sake get a camera tripod.

  • Thanks. Will VS2008 RTM include SQL CE 3.5, CE LINQ to SQL designer and a tool to import data into CE (sdf) file other than RDA and IIS options?

    Ram

  • Hi Scott,

    I'm really looking forward to getting to play around with this. But, I have a question that's been bugging me for a while now.

    I'm wondering how sub-controls are handled. For instance, I might want all product pages to show a user control that lists the contents of your shopping cart.

    I watched the video from the Alt.Net talk you gave and it seems as though I would have to pass the shopping cart data through to the page, then from the page through to the user control embedded in the page. That means I end up putting the shopping cart logic, at least to some extent, into the controllers for every page where I want to show the shopping cart. That seems like a bad approach. Could you explain a little about how the new framework would work for this scenario.

    Thanks

  • Hi Scott,

    Will it be possible to leverage this MVC framework for building WPF applications using XAML and C#, or is it tightly coupled to the ASP.NET Framework. It would be fantastic if the MVC framework is generalized enough that it could be used with ASP.NET as well as winforms and wpf.

    Thanks,
    Gagan

  • Hi Scott,
    how does the MVC framework fit in with the web client software factory? Is there any guidance on which is the preferred method to use for developing a new website?

    Thanks

  • This is wonderful news. I have twice been unable to successfully pitch using monorail in the face of resistance from the legion of Morts (or more specifically, Mort's bosses). I grow bored of lashing something up that fits in this space (and inventing names that don't sound like MVC). So, thanks for that. Now I have to figure out how to best put together linq, mvc, and the new dynamic data controls... aieeee!

  • I have a question about the url scheme.

    I often use a /products/productname approach, but what about all miscellaneous pages - If I don't want to create a controller for each page, will they have to be grouped under e.g. /misc/somepage and /misc/anotherpage? Or can I have /somepage and /anotherpage map to the same controller? Perhaps there's some kind of default controller functionality, that will handle a request if no other controller will?

    I usually allow the creation of "custom" pages from the site cms, where cms users can specify a pretty url themselves. The system then maps this url to e.g. custompage.aspx?id=54.
    Can you make a controller look at the "actual" url (custompage.aspx?id=54) instead of the pretty one?

  • How about VS 2005, can I use it with this version? The USNavy is not allowing us to upgrade to VS 2008 for a few more years.

  • Hi Scott,

    Can we get the code of this sample 'helloworld' application ?

    Thanks

  • I’m new to MVC, so please forgive me if these are dumb questions. I watched the video from the ALT.NET conference and liked what I saw. Since then my team has downloaded MonoRail and has been trying it out. I have a few comments/concerns that I’m hoping Microsoft’s MVC model will address.

    1. We have a pretty robust domain object model which has really good test coverage. I don’t feel like we’re seeing a huge gain in terms of test coverage in that layer. However, it does seem like there’s a lot of gain in testing the actual view. In the MS MVC framework, will we be able to render an aspx page without needing to spin up a webserver? I’m not crazy about NVelociy, but the tests do run really fast. If we have to make a physical web request to test views, I think we’d be better served just using something like WatiN (which I like, but the tests are sloooooooow).

    2. In theory, it seems like there should be a nice way to reuse the controller layer to create web services by just switching from an html view to an xml view. The same could be true for a silverlight application using xaml. Is anything like this already being done?

    Sorry for the long winded question.

  • sound great,heading for a preview

  • 1. Does this mean we'll now be able to test any ASPX page without having to actually spin up a web server? If so, would that be true even without using the MVC model? I'm not crazy about NVelocity, but I can run UI tests much faster then with tools like Watin or AspNUnit.

    2. What about the ability to use MVC where the View actually returns xml? It would be nice to reuse the same controller for both html and web services. Or what about xaml for a silverlight app?

  • WIll the MVC support Persistence? is it the OR Mapper that would render the persistence?

  • Scott,

    I'm curious if you think that controllers might effectively replace http handlers going forward. It sounds like a controller has all the capabilities of a handler without requiring the .ashx file, and with built-in URL routing.

    It also sounds like controllers would be great for outputting json data in response to ajax requests, especially with 3rd party ajax libraries like prototype or jquery. Is this being considered?

    Thanks,
    Roger

  • Looking forward to the preview release

  • An interface based HttpContext alone is a massive improvement.

  • On Scotts video I saw runat="server" tag on the form. So, what's going on????

  • How does this new MVC Framework expected to work with Application Framework like DotNetNuke or Rainbow ? Is MVC Framework a rival technology to DotNetNuke ?

  • Will you offer this framework for .NET framework 2.0 as well?

  • I know this is a little off topic, I've been following this topic for awhile now (and- by extension your blog, which for me (someone who lives and breathes web development and trying to push its development)).. one thing that is somewhat integral to this framework is the url mapping technology..

    The urls mimic that of RESTFUL urls, but do you support a full restful implementation? is that even possible with modern browsers? (such as different verbs)..

    You also stated that 'On IIS7 we can use the new URL mapping features of the web-server to handle this.'..

    My first thoughts about your url mapping was, this will never work on IIS6 and shared hosting.. but then you stated you are also targeting to use IIS7.. so my question is, the url mapping features you speak of in IIS7, are these likely to be usable in shared hosting environments? i.e. is the mapping highly contained? not requiring trust elevation, and so on..

    It just seems that most of our clients simply cannot afford to be on dedicated hosting plans (even if these plans are virtually shared to handle multiple sites to cut costs).. we tend to have to rely on clients purchasing their own 'cheapo' hosting plans (which are really just highly limited medium trust virtual directories)..

  • This is off-topic for this post, but it appears as if comments are closed on this post: http://weblogs.asp.net/scottgu/archive/2006/03/27/441147.aspx

    ...and I had a question for you!

    In that post, you allude to being able to "chain" projects together such that the output of your Web Deployment Project is used by the Build/Publish mechanism of a Web Application Project. I've searched and searched and cannot find reference to anyone doing this. Everyone seems to manually deploy the output of their WDP to the host.

    Was this a vaporware feature or can you point me in the right direction for info on how to do?! Any help is *greatly* appreciated! Thanks!! -N.

  • A late question on this post:

    Is there any provider based customization in the MVC framework? For example, if I want to implement my own Router to get routes out of database, is that kind of customization based on the provider model?

  • I have yet another question, sorry about that but this project is just too interesting!

    Can you briefly touch on ASCX controls or subviews? Do they have their own controllers? Now my user controls have their logic in code behind, and I don't see how I can move that unless they get their own controllers or something like that.

    Thanks!

  • Is there an ETA for a first release of this framework?

  • Isn't MVC retired now? New approch is MVP. Would you elaborate difference between MVC and MVP. Show a sample of MVP.

  • Hi Scott,
    I would like to know what are the difference between MVC and WCSF?
    In what scenarios we need take MVC?
    Thanks

  • Fantastic stuff, can't wait to have a play.

    Not sure if ASP.NET Weblogs allows you to do this, but it would be really nice if your pingbacks and trackbacks could be coloured differently to regular comments. You get a huge amount of them, deservedly, but they're really cluttering your comments section!

  • From last few months I am working on some other technology so bit off track on the new things. Can u please summarize what all models we do have for ASP.NET till the moment and why are we going for something new? I observed frequent changes in Microsoft technologies/tools, and then bug fixes for a while, and again something new. Could you please help in understanding the whole picture of why and how about the new model?

  • I'd be interested in understanding what IDataRepository looks like? Is this how you swap out the datacontext for unit testing? Reason I ask, is one of the significant drawbacks of Linq to SQL is the inability to swap out a DataContext that is bound to SQL with a memory-based DataContext for unit testing. This is a show stopper for us. All it would take is to make IProvider public :)

  • Thanks very much for the artical. We look forwards to see your posts on MVC. Thanks again.

  • Can I ask, just out of interest, what resources were required to develop this -- in terms of man-power, time, etc.

  • Nice,
    Is it different from Enterprise Library?

  • So, WHAT IS BETTER: MVP or MVC (choose only one, stop all the "your preferences" nonsence!)?

    --MS should choose it for us!!!! :)

  • Additional testability compared to webforms is welcome. Many times has my team wished for interface-based HttpContext/Request/Response ;-)

    I'm really curious about what the story is for re-usable components in this model, since that was one of the main areas that ASP.Net pushed forward originally. Using controls for rendering only seems a step backwards.

    Will there be an easy way to invoke a View with a specific data bean in a dev or test setting? Maybe the designer view in VS could expose the bean object in a preview mode?

    A little side-note:
    I noticed a common pattern in your demo, redirecting to the List page after the post on the Edit page. I know that is not in the scope of what your team does (rather a browser problem), but it seems that it would be useful to have a way to do this without redirect, maybe by having a special HTTP header? Making the whole thing backward compatible would be a pain though, I know...

  • Look great. Will it be supported in asp.net 2.0?

  • Wow. It sounds greate.
    A little bit like ASP.Net on Rails? I would like it.

    Will you assist Ajax.Controls or JavaScript Controls like Dojo, too?
    That would be realy great

  • When do we get to start playing with this?

  • When you were asked about whether MVC could be used with WinForms you replied that a single controller could be built for both ASP.NET and WinForms but it would be a custom effort. I too was wondering if I could use MVC with WinForms. I don't want to write the controller myself so my question is whether MVC for WinForms is something that will be coming in the future?

    I am ok with having two different controllers (choose one if WinForm or another if ASP.NET) but its the overall MVC approach and structuring of the code (i.e. separation of concerns) that I would like leverage and apply to WinForm. I'd like to learn one model (i.e. MVC) and apply it to both UI contexts.

  • I know that a ton of people have already been asking about when the initial (beta?) releases were going to be, and I thought I would be just one more guy to ask. Our team is looking to use this to finally upgrade a VB6 Asp application and would love to put it through some of the paces while it's still in development.

  • This is where sometimes I do not know where microsoft is going. They have built such a good factory in the form web client software factory where the view-presenter pattern drives the design and seperation of concerns is take care of. Instead of enhancing the existing factory and including this, why to create something new MVC. It will just confuse more people. Options are better but they need to be unified specially with design patterns as sometimes you can drive developers away with complexity.

    I got I got my point across.

  • Hi Scott,

    Thanks for updating. Could you answer a few questions about MVC.

    1. In an asp.net application, which part (forms, classes, controls etc) represent M-V-C
    respectively.
    2. How does MVC fit in a typical 3-tier architecture (are they two different) and what if
    there are more tiers added? How a typical Presentation, BLL & DAL relate to MVC

    These question will for sure clarify doubts for many of us newbies. Keep up the great work.

  • Havent seen an official reply in about 3 weeks, can we get a more updated time frame of when the initial preview release will be available?

  • ASP.NET MVC Framework developement is a step in a very good way! I wish it will be precious!:-)

    Are you planning to implement some ORM system into this framework? It's usually very used solution to make database Models (e.g. ProductModel etc.)

  • I pestered p&p about a MVC framework/factory a few years ago, and thought the controller implementation would be cool to implement using Windows Workflow. Does this framework use it?

  • This pattern is not new. Look at the Java community and the well know model-2-architecture. JavaServer Faces (JSF) provides a very good concept of defining the control flow in the faces-config.xml file. Good IDEs like Eclispe and the web tools project (WTP) plugin provide a perfectly fitting editor, which allows visually defining the control flow (similar to the editors in BizTalk, SpeechServer, etc.). So I would appriciate to see a similar toolset in Visual Studio soon.

    In the past Microsoft was always very strong in the tools support, but had some weaknesses in architectures, I would like to see your proposed framework with similar concept and tools as JavaServer Faces (JSF) offers currently.

    From an architectural point ASP.NET needs a little bit more, as ASP.NET offers for the developers currently.

  • Kindly post MVC tutorials as promissed. :D

  • Scott, now what is the future of the Model View Presenter and Web Client Software Factory? I think once you've MVC, then no body is going to use MVP.

  • First off, i'd like to say how enthused I am about all the wonderful stuff coming from your teams, and this MVC framework is no exception. With that said, my only notable gripe is for you to please, please get a new cameraman. No offense to you, but when I watch a code-intensive video I'd like to be able to see the code and just hear you, not watch the camera pan around the room and flash shots of code too quickly to absorb. (Hope this helps...lol)

    Thanks, and keep up the good work.

  • hi Scott,

    are you going to open up the source code of the mvc framework?

    and what's the elegant way to color an item on the UI based on a property in a model(e.g. product quantity) with MVC?

  • its really great apporach ...but its only methologies or we have to install any seperate patch of dll for Implementing MVC ASP.Net Framework in my own application

  • Only question - Why so late ? :)

  • Scott, another question, do you think Inversion Of Control container from MS could happen? I know there are at least 2 good (Castle and Spring.NET) but good product from Microsoft is always welcome.

  • In respect of edit actions (post requests), will there be some way to automatically map incomming form data to objects?

  • Hi Eirik,

    >>>>>>> In respect of edit actions (post requests), will there be some way to automatically map incomming form data to objects?

    Yes - we'll be supporting this. I'll blog more about this in the next two weeks.

    Thanks,

    Scott

  • Hi,
    Is this tools already downloadable anywhere ?
    This sounds great :)
    Manitra

  • Hi Scott, nice work with asp.net mvc, very fast preview i might say.
    Could you shed some light on support for subviews or components ( like in monorail ) ?

  • I'm currently using a MVC implementation very similar to the one proposed by Joe Hummel on the WebCast Series "The Architecture of Modern Desktop Apps in .NET". The application begun by been a WinformsApp and now i'm turning it to a ASP.NET rebuilding the UI layer (actually the view and the adapters). Is it going to be hard or worth it, to change from that initial implementation, to this new framework?

  • Its good to see that it supports existing pages and controls.

  • First of all, congratulations for this MVC framework.

    I'd like to ask you some questions. Which is the roadmap when it comes to put in separate metadata (not inside the form) the mappings between Views and actions/commands?

    Also, about WWF, you clarified that today is just for non UI activities. Is there any intention to enlarge it to be able to "redirect" to an UI piece after some non UI action? If this is the case, how could WWF and ASP.NET MVC coexist?

    I'd like to know which seems to be the roadmap about this, and also, if is there any forecast about delivering a true BPM framework (Model / Controller / View / Roles) that could allow to draw flows between activities (understanding as activity both non UI and UI actions) and mapping each activity against role permisions.

    Thanks in advance, and forget me for asking such a lot of questions. But I got really interested when I saw your framework.

    Greetings from Spain, EU.
    PS. My e-mail is alfonso.mateos@grupocastilla.es

Comments have been disabled for this content.