ASP.NET MVC Beta Released

Today we released a beta of the new ASP.NET MVC framework.  Click here to download it.  You can also visit www.asp.net/mvc to explore tutorials, quickstarts, and videos to learn more.

The ASP.NET MVC Beta works with both .NET 3.5 and .NET 3.5 SP1, and supports both VS 2008 and Visual Web Developer 2008 Express SP1 (which is free - and now supports class libraries and web application project types).

Today's ASP.NET MVC Beta release comes with an explicit "go-live" license that allows you to deploy it in production environments.  The previous preview releases also allowed go-live deployments, but did so by not denying permission to deploy as opposed to explicitly granting it (which was a common source of confusion).  Today's release is clearer about this in the license.

The beta release is getting close to V1 feature complete, although there are still a few more features that will be added before the final "V1" release (including several VS tooling enhancements).  The team decided to call this release a "beta", though, because the quality and testing of it is higher than the previous previews (a lot of bug fixes and performance tuning work went into it), and they feel that the core features that are in it are now "baked enough" that there won't be major changes from this release to the final product.

This post contains a quick summary of some of the new features and changes in this build compared to the previous "Preview 5" release: 

I am also planning to publish a few end to end tutorials in the weeks ahead that explain ASP.NET MVC concepts in more depth for folks who have not looked at it before, and who want a "from the beginning" set of tutorials on how to get started.

New "Add View" Menu in Visual Studio

With previous ASP.NET MVC preview releases you had to manually add views through the Project->Add New Item dialog in VS, and creating and wiring up everything required several manual steps (making sure the directory/file structure is right, going into the code-behind file to specify the strongly typed ViewData model type, etc).

Today's beta makes the steps much easier.  You can now just move your source editor cursor to be within a Controller action method in the source editor, and then right-click and select a new "Add View" context menu item (alternatively you can type the Ctrl-M Ctrl-V keyboard shortcut to invoke this without having to take your hands off the keyboard):

This will bring up a new "Add View" dialog that allows you to specify the name of the view you want to create, its master page, and optionally its strongly typed ViewData "Model" type:

 

Visual Studio will automatically pre-populate the view name based on the action method your cursor is within (you can then override this if you want).  For example, if our cursor had been within an "Edit" action method when we selected "add view" it would have pre-populated the view name textbox with "Edit" instead of "Browse".

The strongly typed ViewData "model" for a view can be selected from an editable ComboBox that lists all classes in (or referenced) from the MVC project:

You can either select a type from the list, or manually type one in the ComboBox.  You can also optionally pick an initial type from the list and then tweak it.  For example, we could select the "Product" class from the list and then use the ComboBox editing support to wrap it as an IEnumerable<Product> - meaning a sequence of products:

When we click the "Add" button, Visual Studio will automatically create the appropriate view directory structure, and add a strongly typed view with the right name and base class to our project.  For example, if I followed the steps above it would create a new \Views\Products directory for me (since my controller class name is "ProductsController") and add the strongly-typed "Browse.aspx" view to it (which derives from ViewPage<IEnumerable<Product>> - since that was the model type we indicated in the dialog above):

The newly created view will automatically be opened for us in the IDE.  We can then implement our view with full intellisense (tip: make sure to do a build immediately after creating the view to ensure that intellisense shows up for your strongly typed model):

And at runtime we will now have an SEO optimized product browsing page built with ASP.NET MVC:

Note: The view file created by Add-View with this beta release is empty.  For the final release we are hoping to add some "scaffolding" features to the Add-View dialog that will allow you to optionally specify that you want to automatically create an HTML list/details view or edit/insert form based on the strongly-typed model specified in the add-view dialog (you can then start with this initial html view and tweak it however you want).  In the future we will also integrate ASP.NET Dynamic Data with MVC to support even richer scaffolding options.

New \Scripts directory and jQuery Support

The project template that ships with today's release now adds a new \Scripts directory underneath the project root.  This is now the recommended place to store JavaScript files in your application.

The ASP.NET MVC Beta now adds both ASP.NET AJAX and jQuery libraries to this folder:

The jQuery files are the standard jQuery libraries, and are licensed under the MIT source license (read my previous jQuery and Microsoft post for details).

With the SP1 updates of VS 2008 or Visual Web Developer 2008 Express, you will get basic JavaScript intellisense when using the above jQuery files.  We will be shipping a jQuery intellisense-annotation file in a few more weeks that provides much better and more complete jQuery intellisense support (including the ability to get intellisense when using multiple chained selectors/commands).  This will be included built-in with the next ASP.NET MVC update.

Form Post and Model Binder Improvements

One of the biggest areas of feature investment with the ASP.NET MVC "Preview 5" release was the work around form post scenarios.  I did an in-depth blog post about these form post scenario features last month.

Today's beta includes a number of additional tweaks, enhancements, and refinements in this area.  These include:

Built-in Model Binder support for Complex Types

Preview 5 introduced the concept of "model binders" - which allow you to map incoming form post values to complex .NET types passed as Controller action method parameters.  Model binders in preview 5 were extensible, and you could create custom binders and register them at multiple levels of the system.  Preview 5 didn't ship with any "pre-built" binders, though, that you could use out of the box (you instead had to build your own).  Today's beta now includes a built-in, pre-registered, binder that can be used to automatically handle standard .NET types - without requiring any additional code or registration. 

For example, we can now create a "Person" class like below with standard properties:

And then have a Controller action method take it as an parameter argument simply by writing the code below:

Because the argument parameter above is named "person", the model binder will by default look for form-post values whose key names are in the format "person.Name", "person.Age", "person.Email".  It will then use these values to create and populate a new "Person" object that is passed into our action method.

Developers can optionally override the default name mapping logic using a new [Bind] attribute introduced with today's beta - and by setting its "Prefix" property.  For example, if we set the prefix property to "PersonToSave", the binder would instead look for the following form values: "PersonToSave.Name", "PersonToSave.Age", and "PersonToSave.Email" when creating the person instance.  You can set the prefix to an empty string to have the binder map "Name", "Age" and "Email" with no prefix:

The [Bind] attribute allows you to optionally specify an "Included" or "Excluded" property - which can be used to either "whitelist" or "blacklist" properties from being mapped on the objects.  For example, the code below indicates that we want to map only the "Name" and "Age" properties on our person object:

Important safety tip: In general you want to be very careful to make sure you don't allow properties to be mapped that you don't want mapped.  Always use include/exclude anytime you have properties that you don't want to be mapped on an object.  For example: assuming there was a "Salary" property on our Person object - we would not want to map it unless we explicitly wanted an end-user to be able to set it.  You want to be explicit about not mapping unwanted properties like this to prevent a hacker from trying to fake out a form request and attempting to submit additional property information not editable in the UI.

Refactored Model Binder Infrastructure

The model binder system has been refactored significantly for the beta.  You can now re-use and plug-in functionality in a much more granular fashion when building your own custom model binders.

Model binders are also now used by the UpdateModel and TryUpdateModel methods - allowing you to write one binder and re-use it everywhere any form value is handled inside ASP.NET MVC.

Improved UpdateModel and TryUpdateModel methods

The UpdateModel and TryUpdateModel methods now support several new options and overloads (including richer whitelist and blacklist options). 

It also now optionally supports the ability to just call "UpdateModel" to populate an instance with the default binding rules (with preview 5 you always had to supply a whitelist - and several people asked for an option to just map all):

Another new feature in today's beta is the ability to define a strongly-typed whitelist filter that you use with UpdateModel/TryUpdateModel.  You can do this by defining an interface with the subset of bindable properties that you want to map.  For example, below I'm defining a "IPersonFormBindable" interface that only has three properties (and does not have the salary property):

We could then indicate that we want to use this contract to limit which properties are mapped using code like below:

This will ensure that only those properties defined on the IPersonFormBindable interface are mapped - and that the Salary one is not mapped.

Improved Unit Testing of UpdateModel and TryUpdateModel Scenarios

With Preview 5 you had to use mocking in order to unit test form post scenarios that used the UpdateModel or TryUpdateModel methods.  Today's beta now allows you to unit test all form post scenarios without ever requiring mocking (which enables better friction-free unit testing).

There is a new IValueProvider interface introduced with today's beta that the model binding infrastructure uses to retrieve values to bind (as opposed to always going against the request object).  The FormCollection class (which is built-into the beta) implements this interface - and you can now explicitly pass an instance of this to UpdateModel/TryUpdateModel to bind its values from. 

For example: below in the "Save" action method we are binding all incoming form values to a FormCollection (which will be passed in as an argument to the action method).  I can then pass this form collection to the UpdateModel call and have it map the values onto the person model object using this parameter: 

We could then unit test a successful form post scenario for the above action method using the code below (notice how we don't need to mock anything - instead we can just create a formcollection, populate it, and pass it as a parameter):

We could then unit test an unsuccessful form post (which fails because of invalid input for the age value) using the code below.  Notice how we are verifying that the edit form is redisplayed (so that users can correct their problem) in a form-post failure scenario:

We did not have to mock anything to unit test both of the above form submission scenarios.

Strongly Typed [AcceptVerbs] attribute

ASP.NET MVC Preview 5 introduced a new [AcceptVerbs] attribute that you could use to indicate which HTTP verbs an action method supported. 

In preview 5 you always specified verbs using strings.  We still support this with the beta, but have also added support for common verbs to be specified using a strongly-typed enum mask.  For example:

Today's beta release also no longer requires that you specify [AcceptVerbs] on both actions in scenarios like above.  By default ASP.NET MVC now looks for an action method that explicitly supports the incoming http verb - and if one is not found will use the action method that doesn't have an explicit verb specified.  This saves some typing for common GET/POST scenarios (you no longer need to decorate the GET method).

Validation Error Messages

One of the features that unfortunately did not make it into the beta (but which we will add for the next update) is support so that you can expose custom error validation messages from your model classes (as opposed to customizing them in the Controller like you can do today).  We are currently investigating a few ways to enable this - including adding support for the IDataErrorInfo interface, as well as support for the new Dynamic Data attributes in the System.ComponentModel.DataAnnotations namespace.

One improvement that did make it into today's beta, though, is that the default validation error messages are now more end-user friendly (which hopefully eliminates the need to define custom validation messages in a lot of cases):

HTML Helper Cleanup

Today's beta has some miscellaneous cleanup improvements to the HTML helpers (in general this is a tricky area - since there are so many overload combinations to get right). 

Html.Form -> Html.BeginForm

One of the usability changes made with today's beta was to rename Html.Form() to Html.BeginForm() and to support two modes of using it - one leveraging a using statement, and the other leveraging an explicit Html.EndForm() helper method.  The reason we've moved to support both of these approaches is that we've seen a lot of questions/confusion in the forums around how the using statement works for this scenario (the pattern is unfamiliar to a lot of developers). 

Below are two examples that demonstrate how we can implement the above create screen scenario (complete with validation error message UI) using the two different form approaches:

Approach 1: Using Statement with Html.BeginForm():

The below approach uses the IDisposable pattern with the using keyword in VB and C# to auto-terminate the </form>:

Approach 2: Explicit Html.BeginForm() and Html.EndForm():

The below approach uses an explicit EndForm() call to close the </form>:

Developers can use whichever they feel most comfortable with - both approaches logically do the exact same thing.

Many HTML Helper Methods Moved to be Extension Methods

One change we made with today's beta was to move many of the Html helper methods to be extension methods that live under the System.Web.Mvc.Html namespace (previously they were just instance methods on the HtmlHelper class).  We did a similar thing with the AJAX helper methods in "Preview 5" (they now live in the System.Web.Mvc.Ajax namespace). 

These changes don't impact intellisense in the view markup (we by default automatically reference the namespace in the web.config file so it works just like before - although if you are migrating an app from preview 5 you'll need to add the namespace yourself to web.config, read the release notes for steps on how to-do this).  If you have standalone classes/tests that use the helper methods make sure to add the appropriate "using" statement to import them.

The reason we moved the helper methods to be extension methods instead of instance methods was to provide developers with more flexibility to add/remove/replace our built-in implementations (as well as to give ourselves more flexibility in the future). If you want to override the HTML rendering of a method you can now easily do so - and still keep the same method code/signature in your markup.

Silverlight / ASP.NET MVC Project Integration

When you create a new Silverlight 2 project within Visual Studio or Visual Web Developer 2008 Express (using the recently released Silverlight 2 and VS 2008 Tools for Silverlight download), you now have the ability to select a ASP.NET Web Site, ASP.NET Web Application Project and now an ASP.NET MVC Project to host it within:

When you choose this option, Visual Studio will automatically copy and deploy/update the Silverlight application into the ASP.NET MVC application when you make a change and do a build within the IDE.  This makes it easier to start integrating a .NET based Silverlight front-end (running inside the browser) with an ASP.NET MVC web backend - and opens up some interesting new possibilities.

ASP.NET MVC Futures Assembly

For the last several preview releases, ASP.NET MVC features have been split across two assemblies - System.Web.Mvc.dll and Microsoft.Web.Mvc.dll.  The later assembly + namespace contains "futures" features that hadn't yet been committed to ship in the core V1 product.  As features become "committed" we move them from the futures assembly into the core assembly - and also change the namespace (from Microsoft.Web.Mvc to System.Web.Mvc). 

The previous preview releases automatically shipped and added the "futures" assembly when you did a File->New ASP.NET MVC project.  Starting with today's beta we are no longer automatically adding this assembly - instead you need to explicitly add it from your project if you want to use it.  The reason for this is so that developers can clearly distinguish those features that will be in the fully supported V1 product (which implies product support and a higher commitment around backwards compatibility), and those that might still evolve in the future (and not be added to the supported product until vnext).

Important: the futures assembly (along with all the source code in it) will continue to ship and will work with ASP.NET MVC V1.  So if there is a feature in it you really like, you do not have to worry about it disappearing on you (it is still there and you can still use it).  You just now need to explicitly reference the assembly and use it in your project. 

We plan to ship a version of the ASP.NET MVC Futures assembly that works with the Beta later today.  You will be able to download it here.

\Bin and GAC Deployment

The ASP.NET MVC beta now supports both GAC based deployment (where you install the assembly once for the machine) as well as local \bin based deployment (where you store a copy of the assembly in the application directory). 

We will use the GAC to enable automatic-servicing updates via Windows Update (where an administrator can automatically patch a machine - like they do with the rest of the .NET Framework today, and not have to update each individual application).  One downside with GAC based deployment, though, is that it can make deploying applications that require a GAC component harder for hosted scenarios - since you typically do not have admin access on the server machine (and you need admin rights to install components in the GAC).

To make sure hosted scenarios work well (and to ensure that you don't need your hoster to install anything other that ASP.NET 3.5 in order for ASP.NET MVC to work), we will also support the ability to deploy the ASP.NET MVC framework assemblies in the \bin directory of your application.  This will allow you to just xcopy/ftp the application onto the server and have it work (no admin access or setup needs to be run on it).  The one caveat with this is that you'll be responsible for updating the assembly anytime a servicing update comes out - Windows Update can't automatically find all the application directories on a machine to-do this for you.

Summary

Today's beta release is a step closer to the final ASP.NET MVC 1.0 product.  While not 100% feature complete, we think the major subsystems are all getting really close to being done, and that the quality level is now pretty good.

I am going to try and post some more end-to-end tutorials in the coming weeks that show off how to use ASP.NET MVC from the beginning, and then logically progress to richer and richer scenarios.  Included in the list of tutorials will be my infamous AJAX with MVC post that I keep promising to write - but so far haven't (my excuse: the Silverlight 2, ASP.NET MVC, .NET 4.0, VS10, and Windows 7 ship cycles are all happening in parallel on my team - and I've unfortunately been really busy which is the reason for the delay).

As I always like to make sure I point out: If you don't like the MVC model or don't find it natural to your style of development, you definitely don't have to use it.  It is a totally optional offering - and does not replace the existing WebForms model.  Both WebForms and MVC will be fully supported and enhanced going forward (ASP.NET WebForms in .NET 4.0 will add richer URL routing features, better HTML css markup support, complete control over the ClientId property, more AJAX features, and more that I'll be blogging about soon).  So if you don't like the MVC option, don't worry, and don't feel like you should or need to use it (you don't). 

Hope this helps,

Scott

95 Comments

  • Darn! So now I have to update all my blog entries about using Preview 5 to create a RESTful web service to check they work with the Beta:

    http://shouldersofgiants.co.uk/blog/

    Seriously.... good news that we are now in the end game for a full release. Thanks.

  • cool ... more bits to play with!

  • Hats off to you Scott!

    I have been awaiting this day for a long time, preview after preview - this makes it all worth while!

    Dave The Ninja

  • Would it be possible to have the code as text instead of images? Anyway, great post - as always.

  • Congratulations! When do you foresee hitting that 1.0/supported milestone? I ask because my team is starting on a product that I'd love to use ASP.NET MVC for but my manager won't sign off on a beta in production. I'm not looking for a firm date; I'd settle for an expected quarter.

  • Scott, is there an updated MvcApplicationX to download and see this stuff in action? Thanks!

  • I heart ASP.NET MVC. Makes web programming fun again. Thanks guys!

  • Grats on your release - looks great! =)

  • Already downloaded and converted my project. It's really great to see how this(ASP.NET MVC) is getting better and better

  • Nice Job!

  • Awesome work Scott!!!

  • Hats off to SCOTT GUru and his team!

    >> my excuse: the Silverlight 2, ASP.NET MVC, .NET 4.0, VS10, and Windows 7 ship cycles are all happening in parallel on my team - and I've unfortunately been really busy which is the reason for the delay

    Now that's a lame excuse. Get off your a$$ and work :)

  • Great, it's a big step.

  • I have a problem with things like this.
    Will the compiler pick this up as an error when .Name is change to .FullName or do I have to wait to run the page in order to find this error?

  • the HTML Helper Cleanup is great! Thanks Scott! more Blessings!

  • I've been playing with the new bits for a few hours now and love most of the changes. I have noticed that the Html.SubmitButton helper method has been removed, which strikes me as kind of odd. Even the built-in Login view just uses now. What was the reason for its removal?

  • Hi Josh,

    >>>>>> Would it be possible to have the code as text instead of images? Anyway, great post - as always.

    Sorry about that. My next big tutorial series will have text snippets for the code samples as well.

    Thanks,

    Scott

  • Sorry for post, but there is trouble in my project after preview5 -> beta.
    System.ExecutionEngineException in httpHandler.ProcessRequest(HttpContext.Current); in default.aspx autogenerated file.

    anybody help me in my trouble!
    ps: sorry for my english

  • Hi Bill,

    >>>>>>> Congratulations! When do you foresee hitting that 1.0/supported milestone? I ask because my team is starting on a product that I'd love to use ASP.NET MVC for but my manager won't sign off on a beta in production. I'm not looking for a firm date; I'd settle for an expected quarter.

    The team is working pretty hard to try and get it out as soon as possible. They are feeling confident we'll have an API complete release candidate done this year. Fingers crossed the final RTM release is this year as well - if not it would be the very beginning of next year.

    Hope this helps,

    Scott

  • Hi Steve,

    >>>>>> Scott, is there an updated MvcApplicationX to download and see this stuff in action? Thanks!

    Can you elaborate on the MvcApplicationX comment? I'm not entirely sure what that is. :-)

    Thanks,

    Scott

  • Hi Dave,

    >>>>>> I have a problem with things like this. Will the compiler pick this up as an error when .Name is change to .FullName or do I have to wait to run the page in order to find this error?

    Unfortunately the compiler won't help you with that - since the property name is a string.

    Hope this helps,

    Scott

  • Hi DsWatik,

    >>>>> Will the source still be available...meaning will the beta version source be made available or was that only for the CTP versions.

    Yes - we'll be posting that within the next few days.

    Thanks,

    Scott

  • Hi Shiju,

    >>>>>>> When can we expect a sub controller infrastructure for MVC?

    The team currently has that penciled in for the release immediately following V1. The reason for not having it in V1 are: 1) there are a couple of approaches that could be used for it, and we want to spend a little more time investigating and exploring them (and not bake something prematurely into V1), and 2) there is a subcontroller implementation currently in the MVCContrib project that be used with the V1 release. I'd recommend looking at using that one if you need a subcontroller pattern, and then we'll bake one into the core binary once we feel confident on a final design.

    Hope this helps,

    Scott

  • Hi Troy,

    >>>>>>> I've been playing with the new bits for a few hours now and love most of the changes. I have noticed that the Html.SubmitButton helper method has been removed, which strikes me as kind of odd. Even the built-in Login view just uses now. What was the reason for its removal?

    Have you installed and registered the MVC Futures assembly in web.config? I think this has the additional HTML helpers not in the core - which I think includes Html.SubmitButton().

    Hope this helps,

    Scott

  • Hi Vladimir,

    >>>>>> System.ExecutionEngineException in httpHandler.ProcessRequest(HttpContext.Current); in default.aspx autogenerated file.

    This sounds like something isn't registered right in your web.config file. Have you followed the steps outlined in the release document on how to upgrade from preview 5?

    Thanks,

    Scott

  • I have been following ASP.NET MVC since it was first announced almost a year ago, and I love the concept. I've liked ASP.NET mainly due to it's .NET ties and thus the ability to use VB.NET or C# for my code; however, I've not so much liked how WebForms would always abstract the stateless HTTP and the HTML to be more "WinForms" friendly. In many cases it has made my website development much more difficult than it would have been otherwise. One problem I tend to have with MVC is that it doesn't have very decent support for the already existant built in templating support that VS and ASP.NET have. Current WebControls do work, but aren't "powerful" enough. Most effort has been in creating methods which build HTML to be placed in the page (such as 'Html.TextBox("Username")'). I honestly do not like mixing layout with code (the traditional ASP style), as well, Visual Web Developer designer can't tell what functions are supposed to display. I'd much rather have the MVC style of having requests go directly to a controller that can process the information and display a view, with the templating ability of WebControls.
    e.g. it would be much better to have

    UserName:

    Password:




    rather than:

    UserName:

    Password:




    I have started working on creating such Controls for my own use; however some controls can be more difficult than others, as well as it requires me to copy/paste alot of code directly from the MVC source, as all methods require an HtmlHelper object, which is useless without a ControllerContext, which doesn't exist in design mode, and isn't particularly easy to fake.

    If such never becomes a priority, I assume then I'll have to finish my MVC control library myself as an addon to the framework.

  • Hi Scott
    Are you planning to add some grouping features to the controllers(e.g. in Controllers folder add few subfolders and move controllers to them)? It's a bit hard to orientate when the project is huge and you have about 40 controllers.
    Thanks,
    zihotki

  • When will the Subsonic Scaffolding be available in ASP.NET MVC

  • Hello. Tell me please how to use ASP.NET MVC in more complex AJAX scenarios, such as treeview in modal dialog with async loading treenodes by user request. Or give link to example. Thanks

  • ASP.NET MVC beta released

  • Very nice article, love you :)

  • I'm glad to see the BeginForm(), EndForm() arrive. I don't think that it is an unfamiliarity of developers with the using statement - probably the opposite. It felt to me (and others) that it was a bastardisation of the feature, usually used for exception safe resource management. Also, it is more readable (IMHO) than having an end tag by iself in the script enclosures.

  • "For the final release we are hoping to add some "scaffolding" features to the Add-View dialog....." Are you planning to make this feature template based? So that you can specify a template per project/page type.

  • Lot of cool features, thanks !!!

  • Great news! Thanks for you work.

  • Do you suggest against using MVC Beta 1 in production environment for new projects?

  • Hi Scott,

    Delighted to see the beta, my congratulations to the team.

    I have one problem with UpdateModel that also afflicted Preview 5 (or maybe it's my code ;-) )

    I have a very simple object like this:

    public class MyClass{
    public long Id { get; set; }
    public long Parent { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public bool Active { get; set; }
    public long Category { get; set; }
    private List _childList;
    }

    If my controller action invokes UpdateModel by specifying the property list like this:

    UpdateModel(obj, new [] { "parent", "name", "description", "category", "active" });

    ... then all's well in Pre 5 and the Beta. If I include "id" in the property list (or leave the list out altogether in the beta), I get an InvalidOperationException and the message "The Model of type (whatever) was not successfully updated".

    I need to handle the Id when editing a specific instance, so what have I missed?

    Cheers,
    Roy

  • Hey Scotty, I hate being the millionth person to say this, but really this is absolutely beautiful. You (and Phil) should be extremely proud.

    Quick question: I love the idea of moving the extension methods to a separate namespace... but would it be possible to have the default extensions point to an interface ("IHtmlHelper" or something), so that devs can overwrite the rendering selectively by pointing their extension methods (with the same signature) to the concrete class?

    The reason I say this is because two days ago in my MVC talk at the Sarasota dev group, someone asked a similar question (though he used control adapters as his reference).

    Right now, if I just want to overwrite one method, I would get the following error: "The call is ambiguous between the following methods or properties:..."

    Thanks,
    -Timothy Khouri

  • Hi,

    firstly I have to say that ASP.NET MVC is very nice work and I like it ;)

    Unfortunately I have one big problem with new Beta. When I use as Model some class (Class1) and there are references to another class (Class2) from Class1 and there are references to Class1 from Class2 too then I get StackOverflowException in DefaultModelBinder. I get this problem when I was using some classes from Entity Framework where I have N:1 relationship and so classes are linked this way.
    I did not have this problem in Preview 5 - probably because old ComplexModelBinder does not handle all collections.

    Next thing that I could say is that it could be very good if we could be strongly typed everywhere - so do not use strings to describe actions, controller and views in Controller.RedirectToAction or Controller.View methods and so on. I think that it can be relatively easy maintained using expression trees.

    Thanks!

    Michal Augustyn (maugustyn@seznam.cz)

  • Hi Scott,

    I uninstalled the CodePlex Preview 5 and tried to install the beta, but it failed to install. I tried to inspect the verbose installation log, but didn't find any errors that gave me a clue of what was wrong. Can I submit the log somewhere?

    Regards,

    Lars Wilhelmsen

  • Perfect timing, Scott! I was hoping to have a beta or production release of MVC before Mid-November that was fairly stable.

    Very, very nice to see you guys avoiding strings to get the compile-time checking as well as the explicitness on the UpdateModel, TryUpdateModel, and databinding scenarios. And, of course, the inclusion of jQuery is great to see in the beta.

  • Hi Scott, great job to you and the team for another fine release!

    Does the Beta of the MVC support simple application partitioning (placing controllers and views in sub-folders as well as support for controllers with the same name but differing namespaces?)

    Thanks again
    Kieron and UX Team.

  • Great news! Good work scott!

  • Scott, great news.

    Looking at the new "Add View" option, can we add multiple Views for a single controller OOTB now?

    Thanks

  • I second the w00t from Hanselman and add a FTW!

  • Since you are now including Jquery, which I am extremely stoked about, it seems weird to me to use a dot in the ID's of form elements because it causes problems when using Jquery and CSS. So if I want the element for person.Name I need to do this $("#person\\.Name") which isn't a big deal unless I am using on of the tons of extension to Jquery such as the validation which will pretty much be on every single add / edit scenario for me. Any chance that these object properties could display valid CSS selectors; maybe a dash instead: person-Name?

  • @Max Fraser We'll look into that, but one thing you can always do is override the ID for a form element using the HTML ATtributes dictionary. Something like:

  • To clarify, I'm curious if there will be an updated sample project for download that showcases some of these new features, like model binding, similar to the MvcApplication[x] downloads from your blog previously?

    Thanks

  • Thanks for the ASP.Net MVC tutorials.
    My only question/concern is this:
    The examples, and lot of time was spend on LINQ to SQL.
    Isn't much easier to keep the tables/columns in the database and not bring it in the front end. Using stored procedures/views so changes to the queries can be made inside the stored procedure and hence no need to re-compile and bring the production web sited down if change need to be made?

    I haven't read all the blogs on "LINQ to SQL" but so far nothing i read is over-weighting what i mentioned above.
    Appreciated your take on this.
    Thanks

  • how to deploy on iis6?

  • There is a way to use Controller class that are in a different assembly?

  • Very nice job.
    Now, I wonder if it will be possible to set 1..N names to a controller and its views depending on the current thread culture.
    It could be something interesting so users can view cleaner urls and indexation engines should index better.

    I am french and I have the habit to develop in english (english is shorter than french). But I would like to expose french controllers and view names to my users.

    What do you think about that?

    All the best to the ASP.NET team.

  • Its cool stuff , another mile stone in ASP.net development and much more expected.

  • Hi,

    Very interesting feature...

    PHP guys have this feature before and sometimes posing this to us!

  • i guess time has come for me to check out asp.net mvc. :)

  • Why are the new MVC templates not StlyeCop compliant?

  • I'm really glad to see this. I've always been disappointed that ASP.NET didn't have a flavor of MVC. I've used MVC in a number of projects written in PHP and have always enjoyed working with MVC.
    Mike

  • Hi Scott,

    You say "This makes it easier to start integrating a .NET based Silverlight front-end (running inside the browser) with an ASP.NET MVC web backend - and opens up some interesting new possibilities."

    Could you elaborate on this? What could be an interesting scenario?

  • Congratulations!

    This looks awesome! It is just too bad ASP.Net MVC didn't came before ASP.Net. I am working with some fairly good size web applications and i am asking myself if we couldn't mix parts in ASP.net MVC.
    In all the test case you are running at MS, are there any scenario where you are testing a mix of plain old asp.net 2.0 and asp.net mvc?

    Thanks!

  • I still need mocking in order to unit test the UpdateModel with NUnit. Even if I pass the FormCollection parameter to the controller action I get the ArgumentNullException, saying the controllerContext cannot be null. Any ideas? Thanks.

  • To all the guys that have been breaking their backs on this amazing project, thank you. You will guys are a few clicks away from revolutionizing (i hope) how many people develop for the web with .net.

    THANKS!

  • I've always enjoyed working with the MVC framework on PHP projects. I'm sure glad that ASP.NET has a flavor of it now. But in some respects it seems to be a step backward, no viewstate, page life cycle, asp.net controls, etc.

    Mike

  • Looking forward to those end-to-end tutorials.

  • Scott,

    Up through Preview 5 our Html.Form() statements looked like this:

    <% using (Html.Form(
    controller => controller.RouteUserToRegistration("", ""), FormMethod.Post, Html.Validation().FormValidation()))
    { %>

    However, I see you can't just change Form to BeginForm and expect everything to play nice. Trying to follow the new standard I expected I'd just change it to something like this:



    However, that just blows up in my face with a message that ProfileController cannot be found. Is there something I'm missing?

    Thanks.

  • Hi Scott,

    Is it possible for a controller to specify a view which is not necessarily in the Shared directory nor the "Views\'ControllerName'" directory?


    Thank you.

  • Hi Scott,

    Thanks for the release and tutorials. I am trying to unit test my Controller actions which are saving Posted form values using the FormCollection controller argument and UpdateModel(object, IValueProvider) method.
    However when running the Unit Test I get the following exception:

    Value cannot be null.
    Parameter name: controllerContext

    Any ideas?





  • Scott, Congratulations on reaching Beta status! MVC is the best.

  • I am a bit more concerned on the jQuery integration with MVC. For example the Ajax.Link method which generates a remote function link etc. I know that might not sounds the right model for jQuery (as it should tend to use the unobstructive way to bind the event) but if you guys could go that far to create a native jQuery helper for MVC which does things in the right way and with some help hands to further shorten the code it would be great.

  • very like your vs2008 font setting,would you please email it to me?
    thanks!

    my email: streeman@163.com

  • very like your vs2008 font setting, please email it to me?
    thanks !
    my email:streeman@163.com

  • Hi Scott,
    great job, really.
    Do you think that, having MVC a go-live license, some of the most popular web hosting out there, like DiscountASP.NET, will support it soon, even if still in beta? I'm thinking about using it in my next project already, but without any company supporting it yet I'm not sure about what to do, and I can't wait for the final release, my project release date is in november, it would be a stopper and have me use WebForms.
    Maybe you have news about it...
    Thanks,

    Wasp

  • Wow, I am really loving this! I have leveraged Preview 5 for a production release and am looking forward to updating to beta for an even better (user as well as developer) experience. Awesome!

  • Hi Sven, the Silverlight integration is intriguing to me as an alternative to the traditional views and/or view engine that the "standard" ASP.NET MVC currently employs. Using the Silverlight technology for views, one can essentially create RIAs with ASP.NET MVC. In addition, it provides (IMO) an attractive alternative to the AJAX approach.

  • Scott,

    Here you bind a form to the Person object on the controller.
    Is there anyway to bind a list of Person objects??

    eg.
    public ActionResult Save(IList people)

    Cheers

  • Hi Scott,
    Do you plan to integrate a routing configuration section in web.config for the final release ?

    Thanks,
    Sylvain.

  • 1. If you move 'Scripts' folder outside of 'Content' than it would be good to move 'CSS' (or 'Styles') and 'Images' (or 'Media') folders as well into the root directory and perhaps remove 'Content' folder. Or keep all content files including .js (scripts) files withing 'Content' folder: 'Content/Scripts' etc.

    2. Maybe call it 'ClientBin' instead of 'Scripts', huh? Than developers could place not only .js (script) files into that folder but also Silverlight files.

    3. That would be good if you will allow having access to Model without ViewData prefix. Ex.: instead of

    4. By default create views files without code-behind files (see: http://forums.asp.net/p/1193721/2699126.aspx#2699126)

    5. Have other ideas, if anyone does care..

  • How do I make it work on IIS 5.1?

  • Scott, the "Add View" menu doesn't work here, I have no idea why. Is a bugtracker or something like that available out there, where I can report the bug?

  • Hello Scott,

    Is it possible to have the same behaviour as an Ajax.ActionLink (with the UpdateTargetId attribute), with a BUTTON ?

    Thanks

  • Hello Scott,

    Is it possible to have the same behaviour as an Ajax.ActionLink (with the UpdateTargetId attribute), with a BUTTON ?

    Thanks

  • I can't install as per this forum message - http://forums.asp.net/t/1336453.aspx.
    So, ummm... I'd love to use the MVC beta, but what's wrong with the installer?

  • As far as I know, there's no direct support for using Silverlight as a view technology. It might be possible to build a separate Silverlight app that talks to ASP.NET MVC using web services since web services are a core concept.

    But, Silverlight cannot be used the way Flex (See http://flexiblerails.com/) is used.

    I'll be delighted when someone proves me incorrect. Building a ASP.NET MVC application with virtually no x-browser compatibility issues would be awesome. Mashing the two together would do it.

  • Will Model binding work on CAllback method.

  • I've just built my first application using MVC beta, after the intial battle with the flow of how things fit together development time was reduced dramtically. I love using the inline tags. Congratulations to your team you just made my life easier.

  • Hi Scott,
    How does PreviousPageType work with MVC?

  • hmm. The "Add View" option doesn't work with me either. I tried the repair option but the installer aborted because it thinks I have Web Developer Express and not its SP1 version...

    funny thing is, I only run normal VS2008 :s

  • I'm concerned with security and MVC. The nice thing about viewstate was the fact that the data couldn't be tampered with on the postback. Unless I'm missing something, in MVC you have to revalidate the user has access to delete that itemId. Is that correct?

  • Hi,Scott

    Can you tell us how can the asp.net MVC support muti-language ?

  • Scott,
    I have a question regarding the use of the default binders. Using your example above, you have a [POST]Save method that accepts a complex type like Person. Without applying the Bind(Prefix=..) attribute to the parameter, the view is required to have input fields that are named "Person.Name", etc. I think that is great but my question revolves around the [GET] version of Save. Currently, if I pass an instance of person to the View and input fields are named "Name" instead of "Person.Name", the fields are populated correctly (assume that the fields are rendered as Html.TextBox("Name"); without specifying the data). However, if it is rendered with Html.TextBox("Person.Name"), then it doesn't get populated. Is there a way to retain this functionality or will I have to change the call to Html.TextBox and give it the data to populate it with?

    Thanks.. and as always, I'm loving everything that the MVC team has done!

  • Congratulations to the MVC team - this is a really important addition to .NET for me.

  • I've hit the same problem as Michal Augustyn previous in the comments list.

    "Unfortunately I have one big problem with new Beta. When I use as Model some class (Class1) and there are references to another class (Class2) from Class1 and there are references to Class1 from Class2 too then I get StackOverflowException in DefaultModelBinder. I get this problem when I was using some classes from Entity Framework where I have N:1 relationship and so classes are linked this way."

    Is the plan to make ModelBinding work happily with Entity Framework or should we plan on devising our own model layer between them?

  • Here's my Save action. Note it's similarity with the one you demonstrated:

    public ActionResult Save(Int32 id, FormCollection form)
    {
    using ( ModelBindingDataContext db = new ModelBindingDataContext() ) {
    Country country = db.Countries.Where(c => c.CountryID == id).SingleOrDefault();

    try {
    UpdateModel(country, form);

    db.SubmitChanges();

    return RedirectToAction("View");
    }
    catch {
    return View(country);
    }

    }
    }

    Here's my unit test that fails because of the ArgumentNullException.

    [TestMethod]
    public void Edit()
    {
    // Arrange
    CountryController controller = new CountryController();
    Int32 countryID = 2;
    FormCollection form = new FormCollection();
    form.Add("Name", "Canada");
    form.Add("Iso2Code", "CA");
    form.Add("Iso3Code", "CAN");

    // Act
    var result = controller.Save(countryID, form) as RedirectToRouteResult;

    // Assert
    Assert.IsNotNull(result, "Expected to be redirected on successful POST.");
    Assert.AreEqual("View", result.RouteName, "Expected to redirect to the View action.");
    }

    And just for reference, here is the relevant bits of the Country class:

    public class Country
    {
    public Int32 ID { get; set; } // Primary Key
    public String Name { get; set; }
    public String Iso2Code { get; set; }
    public String Iso3Code { get; set; }
    }

    I assume your examples in this post actually work so what am I missing?

  • @ Doug,

    >>>> What error are you seeing? Your save method looks right - is your view posting to it though? What html form url are you posting to?

    Thanks,

    Scott

  • Hi ScottGU.
    I've downloaded your ASP.NET MVC sample and try to run it. Although I've installed MVC Framework and ADO Entity but it didn't work. There are some error occurred: My IDE cant understand [ControllerAction] attribute above each function in Controller class, so I cant use RenderView void.
    Please tell me why and how do i deal this error.
    Thanks ScottGu.
    Rukowen

  • Hi ScottGU.
    I've downloaded your ASP.NET MVC sample and try to run it. Although I've installed MVC Framework and ADO Entity but it didn't work. There are some error occurred: My IDE cant understand [ControllerAction] attribute above each function in Controller class, so I cant use RenderView void.
    Please tell me why and how do i deal this error.
    Thanks ScottGu.
    Rukowen

Comments have been disabled for this content.