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

Published Sunday, October 14, 2007 10:41 PM by ScottGu
Filed under: , , ,

Comments

# re: ASP.NET MVC Framework

Monday, October 15, 2007 1:56 AM by Francesco

It sounds great. Hardly wait for a public preview!

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:12 AM by 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 ?

Thanks

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:13 AM by Daniel Crabtree

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:20 AM by Ngoc

Hi Scott,

Will MVC Framework be include in VS 2008 RTM?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:21 AM by Kevin Daly

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:30 AM by ScottGu

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 <form runat="server"> control on it.  So controls like <asp:repeater> and other controls work just fine - you'd just use a standard form post or <a href=""> 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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:31 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:34 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:37 AM by J PHILIP

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:43 AM by ScottGu

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

# ASP.NET MVC Framework - ScottGu's Blog

Monday, October 15, 2007 2:44 AM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:45 AM by Mike Moore

@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.  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.  The product model holds your validation rules.  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.  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.  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!

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:48 AM by J PHILIP

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 ?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:54 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:55 AM by Neil

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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:59 AM by Mike

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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:01 AM by ScottGu

Hi Neil,

>>>>>> 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?

The policy around controllers is fairly flexible.  At the base level there is an IController interface that just has a single method - there is then a ControllerBase and Controller base classes that then add more policy and helper methods that controller classes can use.

Our default ControllerBase and Controller base classes do have HTTP awareness.  But if you wanted to build a single controller that worked with both Windows Forms and Web Projects, you could build your own controller base class that implements IController, and then abstracted out the HTTP awareness however you wanted.  This way you could use a single controller for multiple application types.

Hope this helps,

Scott

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:02 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:10 AM by SoftMind

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:16 AM by ChrisNTR

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

# MVC framework update | ChrisNTR

Monday, October 15, 2007 3:19 AM by MVC framework update | ChrisNTR

Pingback from  MVC framework update | ChrisNTR

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:20 AM by Vidar Langberget

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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:22 AM by Brandon Bloom

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 :-)

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:29 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:33 AM by ScottGu

Hi Vidar,

>>>>>>>> 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?

Note that the MVC framework is an optional thing - it doesn't replace the existing webforms model (we'll continue to enhance and support that).  So there is no need to port unless you find the feature-set and approach of the MVC model compelling.

>>>>>>> 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?

You can have a combination of both Web Forms and MVC based UI in the same application - there is no need to use only one or the other.  Instead, you can blend the two together if you find that works best.

Hope this helps,

Scott

# re: ASP.NET MVC Framework

Monday, October 15, 2007 4:04 AM by Kiran

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 4:34 AM by Oyvind Forsbak

Hi Scott,

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

Thanks,

Oyvind

# re: ASP.NET MVC Framework

Monday, October 15, 2007 5:08 AM by Andy Booth

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 5:51 AM by Dan

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 6:04 AM by IronRuby

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

# ASP.NET MVC

Monday, October 15, 2007 6:13 AM by Geek Life

ScottGU posted about the ASP.NET MVC Framework and I have to say I'm highly interested in seeing this in action. I'm pretty busy at this second so I haven't fully reviewed his post or watched the video Scott Hanselmann blogged....

# re: ASP.NET MVC Framework

Monday, October 15, 2007 6:13 AM by Robert Seso

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 6:17 AM by Vikram

wow so many new things coming in Asp.Net. By the way, when are your returning to your posts on LINQ.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 6:36 AM by thatsashok

Thanks scott,

:)

# re: ASP.NET MVC Framework

Monday, October 15, 2007 6:46 AM by 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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 7:12 AM by Alexander Gornik

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

# ASP.NET MVC Framework | Erick Sasse

Monday, October 15, 2007 7:31 AM by ASP.NET MVC Framework | Erick Sasse

Pingback from  ASP.NET MVC Framework | Erick Sasse

# re: ASP.NET MVC Framework

Monday, October 15, 2007 8:24 AM by inisom

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 8:38 AM by Don

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.  

# re: ASP.NET MVC Framework

Monday, October 15, 2007 8:42 AM by 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?

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.

# ASP.NET MVC Framework Coming Soon &laquo; Post Archive &laquo; www.lattimore.id.au

Pingback from  ASP.NET MVC Framework Coming Soon &laquo; Post Archive &laquo; www.lattimore.id.au

# re: ASP.NET MVC Framework

Monday, October 15, 2007 9:23 AM by Matthew

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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 9:24 AM by Joe F.

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 <form runat="server"> 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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 9:26 AM by kane

Awesome!  It can't come out soon enough.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 9:31 AM by Jim

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 9:44 AM by James L

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 9:48 AM by Brendan

This sounds very interesting. We definitely need more and better ways of improving the ease of Test Driven Development.

The more we can have tests written for, the easier maintenance becomes.

I need to give this a shot sometime soon.

Thanks!

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:49 AM by WindowsDave

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:53 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:55 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:58 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:00 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:03 AM by ScottGu

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 <asp:repeater> 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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:05 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:07 AM by ScottGu

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 <form runat="server"> 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 <asp:repeater> 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

# MVC is coming to ASP.NET &laquo; Patrick&#8217;s Bytes

Monday, October 15, 2007 11:14 AM by MVC is coming to ASP.NET « Patrick’s Bytes

Pingback from  MVC is coming to ASP.NET &laquo; Patrick&#8217;s Bytes

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:15 AM by Roger Jennings

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

--rj

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:17 AM by 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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:17 AM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:20 AM by ScottGu

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:

    <%= Html.Link("Push Me", new { Action="Edit", ID=p.ProductId }); %>

Hope this helps,

Scott

# ASP.NET MVC 框架

Monday, October 15, 2007 11:38 AM by Joycode@Ab110.com

【原文地址】 ASP.NET MVC Framework 【原文发表日期】 Sunday, October 14, 2007 10:41 PM 过去的几年里,很多人要求ASP.NET的一件事情就是对使用基于model

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:42 AM by Andy Booth

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:47 AM by Steve400

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:48 AM by Me

ScottGu is a rock star ;-)

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:57 AM by RandomDeveloperGuy

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!

# re: ASP.NET MVC Framework

Monday, October 15, 2007 11:57 AM by Jon Galloway

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! ;-)

# ASP.NET MVC Framework

Monday, October 15, 2007 11:59 AM by Sam Gentile

ScottGu announces the ASP.NET MVC Framework on his blog

# The ASP.NET MVC Framework...

Monday, October 15, 2007 12:12 PM by Denny.NET

The ASP.NET MVC Framework...

# re: ASP.NET MVC Framework

Monday, October 15, 2007 1:55 PM by Daniel Kuppitz

Hi Scott,

imagine an eCommerce site, having the following URLs:

* www.example.com/.../3

* www.example.com/.../5

* www.example.com/.../123

Each of these URLs has its own controller (and only one controller), right? Now, if I have a cart displayed on each of these sites, do I have to implement any cart action in every single controller?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:12 PM by yaip

Looking forward to the tutorials. I hope it also covers topics for MVC newbies.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:17 PM by 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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 2:39 PM by Mike

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?

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:10 PM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:11 PM by ScottGu

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

# ScottGu's first overview of ASP.NET MVC

Monday, October 15, 2007 3:12 PM by Jeffrey Palermo [MVP]

weblogs.asp.net/.../asp-net-mvc-framework.aspx

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:17 PM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:20 PM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:21 PM by ScottGu

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

# re: ASP.NET MVC Framework

Monday, October 15, 2007 3:25 PM by Randy

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

# Scott shares some thoughts about MVC framework for ASP.NET on his web site

Monday, October 15, 2007 3:51 PM by Nermin Dibek

Well, it seems that man himself has spoken about details of this upcoming framework. He has given us

# ASP.NET MVC Framework

Monday, October 15, 2007 5:06 PM by Geeky Storytelling

I know I get asked about MVC/MVP frameworks all the time. Finally have an answer for ASP.NET. ASP.NET

# re: ASP.NET MVC Framework

Monday, October 15, 2007 5:30 PM by Terri Tori

How is this better than using Windows Workflow for MVC?

# MSDN Blog Postings &raquo; ASP.NET MVC Framework

Monday, October 15, 2007 6:16 PM by MSDN Blog Postings » ASP.NET MVC Framework

Pingback from  MSDN Blog Postings  &raquo; ASP.NET MVC Framework

# MVC on a web application with ASP.NET :) (PT/EN)

Monday, October 15, 2007 6:37 PM by Chaves

# { null != Steve } &raquo; Blog Archive &raquo; ALT.NET - MVP - Scott Guthrie

Pingback from  { null != Steve } &raquo; Blog Archive  &raquo; ALT.NET - MVP - Scott Guthrie

# (Re)Assessing Best Practices

Monday, October 15, 2007 8:20 PM by Billy McCafferty

As we progress as developers, we strive to seek out the &quot;best&quot; way to perform our craft. The

# Link Listing - October 15, 2007

Monday, October 15, 2007 9:54 PM by Christopher Steen

Link Listing - October 15, 2007

# ASP.NET MVC Framework

Monday, October 15, 2007 10:04 PM by .Avery Blog

ASP.NET MVC Framework

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:05 PM by Brennan Stehling

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.

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:11 PM by Brian

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)

# re: ASP.NET MVC Framework

Monday, October 15, 2007 10:13 PM by Chad Myers

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 mont