Introducing ASP.NET MVC 3 (Preview 1)

This morning we posted the “Preview 1” release of ASP.NET MVC 3.  You can download it here.

We’ve used an iterative development approach from the very beginning of the ASP.NET MVC project, and deliver regular preview drops throughout the development cycle.  Our goal with early preview releases like the one today is to get feedback – both on what you like/dislike, and what you find missing/incomplete.  This feedback is super valuable – and ultimately makes the final product much, much better.

ASP.NET MVC 3

As you probably already surmised, ASP.NET MVC 3 is the next major release of ASP.NET MVC. 

ASP.NET MVC 3 is compatible with ASP.NET MVC 2 – which means it will be easy to update projects you are writing with MVC 2 to MVC 3 when it finally releases.  The new features in MVC 3 build on top of the foundational work we’ve already done with the MVC 1 and MVC 2 releases – which means that the skills, knowledge, libraries, and books you’ve acquired are all directly applicable with the MVC 3 release.  MVC 3 adds new features and capabilities – it doesn’t obsolete existing ones.

ASP.NET MVC 3 can be installed side-by-side with ASP.NET MVC 2, and you can install today’s “Preview 1” release on your machine without it impacting existing MVC 2 projects you are working on (they will continue to use MVC 2 unless you explicitly modify the projects to retarget them to MVC 3).  When you install “Preview 1” you will have a new set of ASP.NET MVC 3 project templates show up within Visual Studio 2010’s “New Project” dialog – choosing one of those when you create a new project will cause it to use MVC 3.

Below are details about some of the new features and capabilities in today’s “Preview 1” release.  Unless otherwise noted, all of the features I describe are enabled with the preview build you can download and use today.  More ASP.NET MVC 3 features will come in future preview refreshes as we flesh out the product more and iterate on your feedback.

View Improvements

ASP.NET MVC 3 “Preview 1” includes a bunch of view-specific improvements.

Add->View Dialog

“Preview 1” includes a new “Add->View” dialog that makes it easy for you to choose the syntax you want to use when you create new view template files.  It allows you to select any of of the available view engines you have installed on your machine – giving you the ability to use whichever view templating approach feels most natural to you:

AddView9

There are a bunch of great open source view template engines out there (including Spark, NHaml, NDjango and more) – it is now much easier for them to integrate into Visual Studio.

Today’s “Preview 1” build of ASP.NET MVC 3 comes with two view-engine already pre-enabled within the dialog: ASPX and Razor. 

New “Razor” View Engine

Earlier this month I blogged about the new “Razor” view engine we’ve been working on.  Based on the comments in the post, a lot of people are eagerly waiting to use it.  The good news is that you can start using it with today’s “Preview 1” release.

Simple Razor Example

Let’s build a super-simple store site that lists product categories, and allows visitors to click the categories to see a listing of products within them.  You can download a completed version of this sample here.

image

Below is a StoreController class that implements the two action methods (“Index” and “Browse”) needed to build the above scenario:

image

We’ll use the new “Razor” view engine to implement the view templates for our StoreController.

Below is the “Layout.cshtml” layout-page that will define the common layout UI we want across our site.  The “RenderBody()” method indicates where view templates that are based on this master layout file should “fill in” the body content:

image

Below is the view template for the Index action.  It is based on the above layout page, and outputs a <ul> list of category names: 

image

The template above is using the standard Html.ActionLink() helper method in ASP.NET MVC to render a hyperlink that links to the “Browse” action method of our StoreController.  All of existing HTML helper methods in ASP.NET MVC work in “Razor” views – this is true both for the HTML helper methods built-into ASP.NET MVC, as well as those built by others (including vendors and the MvcContrib project).

Below is the view template for the Browse action.  It lists the products within a specific category:

image

Notice above how we are using the “Model” property within our foreach statement to access the strongly-typed List of products we passed from our Controller.  We are doing this just like we would within .aspx view templates.  Razor also supports a “View” property which allows us to access un-typed “ViewData” passed to the view template.  “View” is a dynamic property (a new feature of .NET 4) – which gives us a slightly cleaner syntax when accessing ViewData.  Instead of writing ViewData[“Cateogry”] we can now just write View.Category.

Clean and Concise

The code in the screen-shots above contains everything we need to write to implement our Controller + Views.  “Razor” helps make view templates clean and concise, and I think you’ll find it enables a very fluid coding workflow. Read my “Razor” blog post from earlier in the month to learn more about the syntax and understand how it works.  You can download a running version of the above sample here.

Code Intellisense and Colorization

One of the things you might have noticed from the screen-shots above is that “Razor” file colorization and code intellisense is not yet supported in Visual Studio with today’s “Preview 1” release.  We will be enabling full code intellisense and colorization with a future preview refresh.  The VS 2010 editor will support Razor file intellisense for C#/VB code, as well as for HTML/CSS/JavaScript. 

Other Improvements in the Future

Three other enhancements we are working to enable in a future preview refresh are:

  • The ability to use a @model statement at the top of a “Razor” file instead of having to explicitly inherit from a base class.  This reduces the code and simplifies it.  
  • The ability to specify a default LayoutPage for the site to avoid having to explicitly set it within each view template.  This further reduces the code within the view template, and makes your code more DRY.
  • The ability to unit-test individual “Razor” template files without having to run the application or launch a web-server.

With these first two changes the above Browse template will be able to be written as simply:

image

The above template syntax will be supported in a future preview refresh.  Full colorization and code-intellisense will be provided within the editor.

Controller Improvements

ASP.NET MVC 3 “Preview 1” includes several nice controller-specific enhancements.

Global Filters

ASP.NET MVC supports the ability to declaratively apply “cross-cutting” logic using a mechanism called “filters”.  You can specify filters on Controllers and Action Methods today using an attribute syntax like so:

image

Developers often want to apply some filter logic across all controllers within an application.  ASP.NET MVC 3 now enables you to specify that a filter should apply globally to all Controllers within an application.  You can now do this by adding it to the GlobalFilters collection.  A RegisterGlobalFilters() method is now included in the default Global.asax class template to provide a convenient place to do this (it is then called by the Application_Start() method):

image

The filter resolution logic in MVC 3 is flexible so that you can configure a global filter that only applies conditionally if certain conditions are met (for example: debugging is enabled, or if a request uses a particular http verb, etc).  Filters can also now be resolved from a Dependency Injection (DI) container – more on that below.

New Dynamic ViewModel Property

ASP.NET MVC Controllers have supported a “ViewData” property that enables you to pass data to a view template using a late-bound dictionary API.  For example:

image

The “ViewData” API is still supported in ASP.NET MVC 3.  MVC 3 augments it, though, with a new “ViewModel” property on Controller that is of type “dynamic” – and which enables you to use the new dynamic language support within VB and C# to pass ViewData items using a slightly cleaner syntax than the current dictionary API.  Now you can alternatively write the following code to achieve the same result as above:

image

You do not need to define any strongly-typed classes to use the ViewModel property.  Because it is a “dynamic” property you can instead just get/set properties on it and it will resolve them dynamically at runtime.  It internally stores the property name/value pairs within the ViewData dictionary.

New ActionResult Types

ASP.NET MVC 3 “Preview 1” includes several new ActionResult types and corresponding helper methods.

HttpNotFoundResult

The new HttpNotFoundResult class is used to indicate that a resource requested by the current URL was not found. It returns a 404 HTTP status code to the calling client. You can optionally use the new HttpNotFound() helper method on Controller to return an instance of this action result type, as shown in the following example:

image

Permanent Redirects

The HttpRedirectResult class has a new Boolean “Permanent” property that is used to indicate whether a permanent redirect should occur. A permanent redirect uses the HTTP 301 status code.  In conjunction with this change, the Controller class now has three new methods for performing permanent redirects: RedirectPermanent(), RedirectToRoutePermanent(), and RedirectToActionPermanent().  These methods return an instance of HttpRedirectResult with the Permanent property set to true.

HttpStatusCodeResult

The new HttpStatusCodeResult class can be used to set an explicit response status code and description. 

JavaScript and AJAX Improvements

ASP.NET MVC 3 includes built-in JSON binding support that enables action methods to receive JSON-encoded data and model-bind it to action method parameters. 

To see this feature in action, consider the jQuery client-side JavaScript below.  It defines a “save” event handler that will be invoked when a save button is clicked on the client.  The code within the event handler constructs a client-side JavaScript “product” object with three fields whose values are retrieved from HTML input elements.  It then uses jQuery’s .ajax() method to POST a JSON based request containing the product to a /Store/UpdateProduct URL on the server:

image

ASP.NET MVC 3 now enables you to implement the /Store/UpdateProduct URL on the server using an action method like below:

image

The UpdateProduct() action method above accepts a strongly-typed Product object as a parameter.  ASP.NET MVC 3 can now automatically bind the incoming JSON post values to the .NET Product type on the server – without you having to write any custom binding or marshalling logic.  ASP.NET MVC’s built-in model and input validation features all work as you’d expect with this.

We think this capability will be particularly useful going forward with scenarios involving client templates and data binding (like I’ve previously blogged about here).  Client templates will enable you to format and display a single data item or set of data items by using templates that execute on the client.  ASP.NET MVC 3 will enable you to easily connect client templates with action methods on the server that return and receive JSON data.

Other JavaScript/AJAX Improvements in the Future

Future preview refreshes of ASP.NET MVC 3 will include better support for unobtrusive JavaScript.  ASP.NET MVC 3 will also directly support the jQuery Validation library from within its built-in validation helper methods.

Model Validation Improvements

ASP.NET MVC 2 came with significant model validation improvements.  You can read my previous blog post to learn more about them.

ASP.NET MVC 3 extends this work further, and adds support for several of the new validation features introduced within the System.ComponentModel.DataAnnotations namespace in .NET 4. In particular:

  • MVC 3 supports the new .NET 4 DataAnnotations metadata attributes such as DisplayAttribute.
  • MVC 3 supports the improvements made to the ValidationAttribute class in .NET 4.  The ValidationAttribute class was improved in .NET 4 to support a new IsValid overload that provides more information about the current validation context, such as what object is being validated.  This enables richer scenarios where you can validate the current value based on another property of the model. 
  • MVC 3 supports the new IValidatableObject interface introduced in .NET 4.  The IValidatableObject interface enables you to perform model-level validation, and enables you to provide validation error messages specific to the state of the overall model, or between two properties within the model. 

Below is an example of using the IValidatableObject interface built-into .NET 4 to implement a custom validation method on a class.  This method can apply validation rules across multiple properties and yield back multiple validation errors (and optionally include both an error message like below as well as a list of property names that caused the violation):

image

ASP.NET MVC 3 now honors the IValidateObject interface when model binding (in addition to all of the other validation approaches it already supported with MVC 2), and will retrieve validation errors from it and automatically flag/highlight impacted fields within a view using the built-in HTML form helpers:

image

ASP.NET MVC 3 also introduces a new IClientValidatable interface that allows ASP.NET MVC to discover at runtime whether a validator has support for client validation.  This interface has been designed so that it can be integrated with a variety of validation frameworks.  MVC 3 also introduces a new IMetadataAware interface that simplifies how you can contribute to the ModelMetadata creation process. 

Dependency Injection Improvements

ASP.NET MVC 3 provides better support for applying Dependency Injection (DI) and integrating with Dependency Injection/IOC containers.

In “Preview 1”, we’ve added support for dependency injection in the following places:

  • Controllers (registering & injecting controller factories, injecting controllers)
  • Views (registering & injecting view engines, injecting dependencies into view pages)
  • Action Filters (locating & injecting filters)

For future previews we are investigating adding dependency injection support for:

  • Model Binders (registering & injecting)
  • Value Providers (registering & injecting)
  • Validation Providers (registering & injecting)
  • Model metadata Providers (registering & injecting)

ASP.NET MVC 3 will support the Common Service Locator library, and any DI container that supports it’s IServiceLocator interface.  This will make it really easy to integrate any DI container that supports the Common Service Locator with ASP.NET MVC.

Note: In Preview 1, we redefined the CSL interface in our codebase, and didn’t include the CSL DLL in our setup. This means that existing implementations of CSL won’t “just work” with “preview 1” – instead they’ll have to recompile their CSL implementations against our interface to make them work. Future preview refreshes will make this CSL library dependency easier, and avoid this extra step.

Brad Wilson is starting a great blog series on ASP.NET MVC 3’s Dependency Injection Support.  Below are links to his first few articles about it:

Click here to download a simple ASP.NET MVC 3 example that demonstrates how to use the popular Ninject Dependency Injection Container with ASP.NET MVC 3. 

Downloads and Links

Click here to download ASP.NET MVC 3 Preview 1.  Post feedback/issues about it in the ASP.NET MVC Forum.

Once ASP.NET MVC 3 is installed, you can download and run the simple Razor sample I demonstrated in the blog post above. 

Read my previous “Razor” blog post to learn more about how it works and its syntax.  Also read my recent EF4 Code-First and EF4 Code-First Schema Mapping posts to learn more about the database code and clean model layer I built using EF4 Code-First and SQL Express within the above sample. Listen to Scott Hanselman’s Podcast about ASP.NET MVC 3 with Phil Haack, and watch this Scott Hanselman Channel 9 video about ASP.NET MVC 3.

Summary

We are excited to get today’s ASP.NET MVC 3 “Preview 1” release in people’s hands, and start receiving feedback on it. 

Our primary goal with these early preview releases is to get feedback – both on what you like/dislike, and what you find missing/incomplete.  This feedback is super valuable – and ultimately makes the final product much, much better.  If you do install today’s “Preview 1” build, please post your feedback and any bugs/issues you find to the ASP.NET MVC forum at http://forums.asp.net.  The team will be monitoring this forum closely, and will be happy to help with anything you run into. 

We will then iterate on the feedback you send us, and further refine ASP.NET MVC 3 in future preview refreshes.

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

Published Tuesday, July 27, 2010 9:06 AM by ScottGu

Comments

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:16 PM by Eldho

Great...this will go miles ahead.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:21 PM by Mike

Awesome!, great work.

Mike

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:25 PM by Matteo

Hi Scott! Kudos to all the team! Great work, it seems delicious! Is the roadmap already known?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:28 PM by Vitor Canova

Ok. It's time to learn about ASP.NET MVC. Very good work.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:31 PM by Dan Diplo

The changes all look great, Scott. But do you need Visual Studio 2010 for MVC3 or will it work in 2008?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:36 PM by Harman

Great....nice to hear

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:53 PM by Herberth Amaral

Cool! It is really getting better!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:54 PM by Anon

This is great! Love the new view engine.

Has someone verified whether this works under Mono on Linux?

Thanks!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:57 PM by korggy

Will you be fixing [ValidateInput(false)] to work with the new ASP.NET 4 input validation pipeline? Currently ValidateInput(false) is broken unless you set <httpRuntime requestValidationMode="2.0" /> in the config.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:57 PM by Anonymous

Are you guys on meth?? MVC is just rocking!!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 12:58 PM by lynn

Scott, will future previews include improvments around Doughnut & Doughnut Hole caching?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:03 PM by Danny

I'm glad it's backwards compatible.  These releases are coming really quickly.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:03 PM by lynn eriksen

Love the JSON binding!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:07 PM by Vladimir

Awesome, Scott!

One question: how about source codes of MVC3 P1?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:09 PM by Ryan Heath

I see @RenderBody, but is there a way to render arbitralely code blocks?

For instance, a certain view might need a specific javascript include, which should appear in the head of the html.

// Ryan

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:14 PM by Denny Ferrassoli

Awesome set of improvements. Really like the JSON binding and DI improvements. Thanks!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:16 PM by q42jaap

Well done! Hope the final version will be out there sooner than March 2011?!?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:18 PM by Duy Nguyen

It's very cool. Love new View engines and Dynamic ViewModel property.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:31 PM by Shlomo

Love most everything. Hate the dynamic ViewModel (at least so far). There's no type checking, so why make the syntax look like there is?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:38 PM by koistya

Maybe NotFound() helper method will be better? Ex.: return NotFound();

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 1:43 PM by John Zablocki

Any chance of sneaking a SkipFilter attribute in there?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 2:08 PM by Allan Ferreira

Great job! Awesome job! A couple of questions, Scott: 1) Is there any intention of adding syntax highlight and intellisense for Razor on the IDE? 2) How can do the tooling aware of the view engines I have "installed" on my computer?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 2:13 PM by XIII

Congratulations on the release of MVC3. Looking forward to the final product.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 2:30 PM by Edward J. Stembler

Scott, these are great improvements!  I really love how Microsoft keeps coming out with timely, incremental updates!

Now, if only the MVC library properly supported the DLR languages, IronPython & IronRuby...

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 2:36 PM by Alan

This feels like a 2.1 release, not a 3.0, why is the MVC team so eager to hike the version numbers so quickly, a 3.0 should be a huge shift in development compared to 2.0, I'm not seeing that, just minor incremental improvements (which are appreciated).

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:12 PM by Fikret AKIN

Thanks Scott,

DBML support here? If e goes EDMX..

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:31 PM by John

@Alan, Version 3.0 will sell more "Professional ASP.NET MVC 3" books by Guthrie et al.    It should be 2.5 at most.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:33 PM by ScottGu

@Dan,

>>>>>>>>>>> The changes all look great, Scott. But do you need Visual Studio 2010 for MVC3 or will it work in 2008?

ASP.NET MVC 3 takes a dependency on .NET 4 (for a lot of the features I listed above), so you do need VS 2010 since that is the only version of VS that works with .NET 4.  You can though use Visual Web Developer 2010 Express (which is free) if you don't have VS 2010 installed.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:34 PM by ScottGu

@Anon,

>>>>>>>>> Has someone verified whether this works under Mono on Linux?

It should work.  I don't know of someone who has tried it yet - but it should work.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:34 PM by ScottGu

@korggy,

>>>>>>>>> Will you be fixing [ValidateInput(false)] to work with the new ASP.NET 4 input validation pipeline? Currently ValidateInput(false) is broken unless you set <httpRuntime requestValidationMode="2.0" /> in the config.

Thanks for the suggestion - I'll forward it along to the team.

Thanks,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:36 PM by ScottGu

@lynn,

>>>>>>>>>>> Scott, will future previews include improvments around Doughnut & Doughnut Hole caching?

That is something we'll be looking at.  Better caching helpers are on the list to make better.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 3:37 PM by ScottGu

@Vladimir,

>>>>>>>>>> One question: how about source codes of MVC3 P1?

I'm not sure whether it is available for download today - but it is definitely coming soon.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 4:10 PM by Linda

Great work !

Can't wait for the colorization. The views looks so ... naked :-)

I can't get the Ninject sample to work though.

In NinjectServiceLocator.cs -> GetInstance(Type serviceType, string key) I get the following exception.

Error activating IControllerFactory

No matching bindings are available, and the type is not self-bindable.

Am I missing something obvious here ?

Linda

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 4:32 PM by DalSoft

Really like that ViewData now makes use of the dynamic type.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 4:33 PM by ScottGu

@Ryan,

>>>>>>>> I see @RenderBody, but is there a way to render arbitralely code blocks?  For instance, a certain view might need a specific javascript include, which should appear in the head of the html.

You can provide optional overrides and use the @RenderSection() helper to fill in other regions of the page.  You could this approach to accomplish this I think.

Thanks,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 4:34 PM by ScottGu

@John,

>>>>>>>> Any chance of sneaking a SkipFilter attribute in there?

Can you send me email (scottgu@microsoft.com) with more details about this suggestion?  I can then forward it onto the team.

Thanks,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 4:36 PM by ScottGu

@Allan,

>>>>>>>> Great job! Awesome job! A couple of questions, Scott: 1) Is there any intention of adding syntax highlight and intellisense for Razor on the IDE?

Yes - full code intellisense and colorization support will be provided in VS wit the next preview refresh.

>>>>>>>> 2) How can do the tooling aware of the view engines I have "installed" on my computer?

View engines can add appropriate templates into a specific folder which will cause them to show up within the Add->View dialog.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 4:37 PM by ScottGu

@Alan,

>>>>>>>>> This feels like a 2.1 release, not a 3.0, why is the MVC team so eager to hike the version numbers so quickly, a 3.0 should be a huge shift in development compared to 2.0, I'm not seeing that, just minor incremental improvements (which are appreciated).

We have even more features coming - today's refresh was just the first preview. :)

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 5:03 PM by vladan strigo

Hi Scott,

Would it be possible to include also into dialog for create controller the template choosing? so that we could have our own templates like crud template, complicated crud template, empty controller template and such?

Also, do you have plans to make better the current display and editor templates (e.g. include a dropdownlist template which takes data from viewdata, and selects the current item from viewdata model)?

Thanks!

Vladan Strigo

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 5:30 PM by mike johnson

Good Job!

the developer story continues to be one of the best stories comming from microsoft these days. We just transitioned our app to MVC2 and its paid off in spades. The razor engine and the next version of MVC look to improve what we have already.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 6:14 PM by Andreas

Thanks Scott, been waiting for this release!

If you want HTML colorization with .cshtml files in VS2010. Try these steps:

1. Open Tools menu.

2. Choose Options.

3. Go to Text Editor, and third choice; File Extension.

4. Enter cshtml as Extension and choose HTML Editor in the dropdown.

5. Click Add and OK. Now try to open a .cshtml file – you should get HTML colorization.

It sure helps on the eyes!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 6:33 PM by dicoo

This sounds nice and all, but what "cool new features" is planned for the next webforms release.

The 4.0 version have some nice features, like routing, but there were no real wow factor. It just felt more like a 2.5 version.

So it would be nice if you could blog a little more about whats coming up for us not so trendy webform devs.

Cheers

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 6:39 PM by Socrates470BC

In the view engine dropdown, one of the options is ASPX (C#).

Does that mean that there is no support for ASPX (VB)?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 7:05 PM by Jimmy

Can you define client side validation for IValidatableObject like you would for custom validation attributes?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 7:10 PM by Daniel Steigerwald

Nice to see HTML5 doctype, but I would prefer lowercase version <!doctype html>

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:09 PM by ScottGu

@Vladan,

>>>>>>>> Would it be possible to include also into dialog for create controller the template choosing? so that we could have our own templates like crud template, complicated crud template, empty controller template and such?

That is definitely something we'd like to do - although we aren't sure just yet where it fits on the schedule.

>>>>>>> Also, do you have plans to make better the current display and editor templates (e.g. include a dropdownlist template which takes data from viewdata, and selects the current item from viewdata model)?

I'll kick off a thread with the team on that - I agree it would be great to try and make that easier.

Thanks,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:10 PM by ScottGu

@Andreas

>>>>>> If you want HTML colorization with .cshtml files in VS2010. Try these steps:

Good tip!

Thanks,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:11 PM by ScottGu

@dicoo,

>>>>>>> This sounds nice and all, but what "cool new features" is planned for the next webforms release.  The 4.0 version have some nice features, like routing, but there were no real wow factor. It just felt more like a 2.5 version.  So it would be nice if you could blog a little more about whats coming up for us not so trendy webform devs.

I'll definitely be blogging more about some cool WebForms features in the weeks ahead as well.  Stay tuned.

Thanks,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:12 PM by ScottGu

@Socrates470BC

>>>>>>>>> In the view engine dropdown, one of the options is ASPX (C#).  Does that mean that there is no support for ASPX (VB)?

The project I was in was a C# project - which was why only C# options showed up by default in the Add->View dialog.  If you create a VB ASP.NET MVC project then you'll see the VB templates show up in place of the C# ones.  VB is definitely supported for both .aspx and Razor templates.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:14 PM by andrewjboyd

Hi Scott,

Are there any plans for having a class attribute that dictates which request it is bound from?  For example, a search/maintenance form scenario, I might search by name (all get requests), I edit a record and the name of the posted record is now populating my search state object, even though the search state is still in the get request.

Regards,

Andrew

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:25 PM by Chris Stott

Great update. Congratulations.

Can't get the JSON binding to work, though? Is there some sample code anywhere?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:25 PM by Piers Lawson

Great to see you are keeping up the momentum!

Any news on the RESTful web services support that was trialled in MVC Futures? Also, what about razor supportting intellisense against an arbitary schema, not just HTML/CSS/JavaScript?

Piers

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:40 PM by Piers Lawson

Just spotted the comment regarding HTML Colorization in VS2010... using the "XML (Text) Editor" would give me what I want in terms of defining a schema... but what would be really cool would be if a Power Tool update for VS2010 allowed you to enter Extensions into that Tool/Options/Text Editor/File Extension dialog of the form xml.cshtml. Unfort. it doesn't like the additional period :-(

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 8:57 PM by Gene

Will razor be available for mvc 2.0? Or only 3.0?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, July 27, 2010 10:58 PM by MobileMagic

As said by Chris Scott I also not able to get the JSON binding to work. Do you have some sample?.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 3:48 AM by RoBYCoNTe

Wonderfull! ASP.NET MVC 2 is great, but with Razor and other features is Very Great!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 4:07 AM by Fernando urkijo

Nice Work! the new view engine it's fantastic! and  more easy to work with.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 4:26 AM by Fernando Urkijo

When are you going to support intellisense on razor views?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 5:57 AM by Fabian

Tuesday, July 27, 2010 8:57 PM by Gene

Will razor be available for mvc 2.0? Or only 3.0?

----------------------------------------------------------

Will there be any final release of any of the new features (especially Razor) before 3.0?

Amazing stuff btw, keep it up!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 6:33 AM by tobias123

"oh no" - damn, another newer release haunts another...

it's pretty hard to keep up with new technology changes in asp.net and around it (including mvc, wcf, linq, entity framework, odata and so on and on) if you (still) have to implement big web applications and have to realize new ordered projects.

nowadays i think it could be a full time job itself just to keep up with all the new .net technologies by reading only a few .net team members blogs like yours, scott.

hopefully the more evolving "convention over configuration" principle will make a lot of it easier very soon, including new APIs, versions, technologies and libraries.

do you have any plans on finishing with your mvc 2 blog series: weblogs.asp.net/.../asp-net-mvc-2.aspx ?

you really should improve this website/blog - at least:

- people should find blog series (MVC2; ASP.NET 4.0; ASP.NET 3.5; 3.5 SP1; Linq ...) more easyly ("categorie/blog series" links or something like that - the tag cloud isn't working very well for this)

- add a published-date to every post

thanks for blogging, tobi

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 7:58 AM by Neil Kinnish

Hi Scott,

Firstly, Thanks for the update and great work from you and your team.

Had an issue getting the new JSON binding to work. Had to register JsonValueProviderFactory manually within global.asax...

ValueProviderFactories.Factories.Add(new JsonValueProviderFactory());

I may have missed something but this works.

Thanks.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 9:29 AM by ciupazMI

Hi Scott,

do you know when the ASP.NET MVC 3.0 Final Release will be available?

Thanks.

Luigi

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 11:23 AM by Seth Jeffery

MVC 3.0 introduced already and it's been less than a year and half since MVC 1.0 was released!! Does this mean I have to upgrade my website again? MVC team I appreciate all that you guys are doing and these features look awesome... but can you give the community a chance to come to grips with all the features of one version before bringing out a major version upgrade? Every time it happens it makes a lot of our code obsolete!!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 12:23 PM by George Steel

Is there any way of using a razor view from an HttpHandler instead of a controller action?  I am working on a web application which needs some needs to send several rendered templates sequentially on the same HTTP Response (in a multipart/x-mixed-replace stream).  Currently, I am using Spark to do this and I would like to switch to razor if I can.

Is there any way i can do this?

Thank you,

George Steel

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 1:15 PM by Jon Davis

What about "@name" type of content? For example, throughout these comments, participants are saying stuff to each other using "@username" as notation, which is content. Will we have to use @"@"username or some other lame workaround? I suppose this would really be a corner case scenario since usually such content is data-driven / dynamic, not static.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 2:29 PM by Thanigainathan

Thanks for sharing such an awsome article on MVC .I am happy to download and install that immeditely.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 3:11 PM by mfeingold

I am about to release another version of NDjango editor extension with better intellisense support for strongly typed models. You made me think that it might make sense to provide an integration with ASP.NET MVC 3. I will need some information though - i.e. how can I have my template wizard access the model name selected in add view dialog. Any advice on where to get such information?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 5:04 PM by Allan Ferreira

@Scott

>>>>>>>> 2) How can do the tooling aware of the view engines I have "installed" on my computer?

>>>>>>>>View engines can add appropriate templates into a specific folder which will cause them to show up within the Add->View dialog.

What folder would be that?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, July 28, 2010 10:18 PM by Paul

Scott,

Great article, as always.  Between the dynamic viewdata, Razor view engine, improved DI support, and global action filters, this is starting to feel like the best parts of Rails + the best parts of .NET rolled tidily into one.

One thing that felt a bit off & out of place to me is the PermanentRedirectXXX methods the team added to controllers.  The permanentRedirectResult is a very useful result to have, in certain niche scenarios.  It doesn't strike me as something that's as commonly useful as ViewResult, JsonResult, or regular RedirectResults.  Since it's not likely to be as commonly used, it feels like you're bloating the controller w/ methods for no good reason, especially when you could accomplish the same thing by just adding a default parameter onto the existing redirect methods, something like isPermanent=false (since you're already dependant on 4.0...)

Anyway, just my nitpick.  Looks great!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, July 29, 2010 12:22 AM by Itzik Yitzchaki

Good work! A few notes through.

1. Adding global namespaces to pages through web.config (<pages><namespaces><add namespace="Web.UI.Helpers" />), don't seem to be honored. I have to use @using in each view instead.

2. Is global filters better then just using a base controller with all the filters on it?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, July 29, 2010 1:31 AM by Shalvin P D

Wonderful to see Asp .Net MVC 3 Preview 1 and Razor in action.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, July 29, 2010 3:53 AM by Eran

Scott, please please please do not forget to include the ability to return multiple views in mvc3 - I am hoping this will come in a future release? Without it, everything that mvc stands for is taken away. Thanks.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, July 29, 2010 9:53 AM by Aylin Erkul

Great article.

Thank you.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, July 29, 2010 6:22 PM by M.M.F

Coool :)

Thank you.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, July 29, 2010 9:41 PM by Maran

I am still trying to learn MVC2 but MVC3 is already out....

Scott take Vacation.......)

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 12:46 AM by Criação de Site

Wow... good job man..

MVC3 will be just .NET4 ?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 2:06 AM by suhair

Am i missing something? where is the source code?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 5:18 AM by Karan Misra

Hey Scott,

How about a few inbuilt filters for helping users implement PRG pattern? I am sure it would be appreciate quite a lot (ViewData -> TempData and back... or any other recommended way)

Regards,

Karan

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 5:36 AM by Tomas

I vote for the donut caching and solid support for binding of non-consecutive collection indexes (not the hidden field with .index) for the next version..

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 7:25 AM by Graham

Is there any plans to integrate the subcontroller concept into MVC 3.0? This was an MVCContrib addon for 1.0, wasn't available in 2.0 and isn't available in 3.0 either. I'm sorry, but Areas and Partial Views are just not the same thing.

I know there's debates about whether a partial view is the same as a user control or not, but the surely it's a common requirement to share view AND controller logic across several different parent controllers?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 11:50 AM by Corey Gaudin

I hope that it will support MEF as an option for DI. I realize it doesnt do things like a typical IoC would do, but there is some real potential for setting up the pieces to be as imports, and we simply setup our versions as Exports and if set a setting on the Global Code to tell it to use MEF, it simply pulls in the exports. Thoughts?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 11:50 AM by ankit.sri

Looks very much similar to Classic ASP, can this be integrated with VS 2008 ?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, July 30, 2010 2:02 PM by ngiotta

Great stuff Scott.  Any chance of posting this in VB for those of us who prefer a language syntax that doesn't resemble pig latin?

Thanks!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Saturday, July 31, 2010 2:14 AM by Abhishek

Hi Scott,

I have seen one of you video in which u said that ASP.net MVC is like Bike while

ASP.net webforms can be considered as CAR. Diffference depends upon requirements

of project and size perhaps.

So, i basically wants to know that with this release of MVC , does it comes somewhat

more closer to web forms in terms of capabilities.

May be little awkward question  but i think i cant get exact words to elaborate what

really i want to ask.But i hope u got what i m trying to ask?   :)

# re: Introducing ASP.NET MVC 3 (Preview 1)

Saturday, July 31, 2010 4:22 AM by cvertex

I know you've tried hard to gives the "dynamic" View (in the page) and ViewModel (in the controller action) the same name, but I think you should try harder. The disparity in names between "View" and "ViewModel" is a bit misleading and confusing, why not go with "ViewModel" in action and view.

That's my only complaint after seeing all the cool stuff you've done. Can't wait to play with preview2

# re: Introducing ASP.NET MVC 3 (Preview 1)

Saturday, July 31, 2010 1:59 PM by Denis

I think you should integrate T4MVC in asp.net mvc.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Saturday, July 31, 2010 9:29 PM by Martin Qian

Good. My team is studing MVC2, I think it is significant to us to understand our direction.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 1, 2010 3:53 AM by mick

Any plans to beef up test automation for mvc 3? its one area that rails still has the edge.

gr8 work.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 1, 2010 3:07 PM by British Developer

Scott, you develop faster than I can learn - I haven't finished Steve Sanderson's MVC 2 book yet! Actually I'm only reading that to concrete up my experience so keep it up and BRING IT ON!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Monday, August 2, 2010 3:04 AM by Sosh

I would ask that the display and editor templates are improved upon in MVC3.  These have the potential to be really useful, but they're not really ready for the big time in MVC2 in my opinion.  E.g. Better support for dropdowns in the editor, better support for editing complex objects.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, August 3, 2010 9:01 PM by steve

What no Xml Action Result? I probably missed something, and I'm newish to it but in MVC2 I can auotgenerate JSON from a LINQ expression but not XML ?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, August 4, 2010 6:43 AM by Jón Trausti

This is looking great. I like the built-in JSON binding. This will definitely make my work easier in the future.

Thank you for the great preview.  

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, August 5, 2010 2:54 AM by Nripendra n. newa

I would ask for ways to write controller logic without having hard dependency on the Httpcontext(May be with help of Dependency Injection). This will help to write clean controllers without any dependency on the httpContext, and helps in which in turn helps in writing more testable controllers.

Thank you.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, August 6, 2010 9:19 AM by Chris

I like these enhancements, I live MVC, but I still like ASP.NET WebForms.

What I really want is a mix.... I want to be able to create pages where:

1. I have complete control over the markup and my markup could be literal javascript objects if that's what I want or standard html markup.

2. Controls to produce markup or at least a framework that allows me to create them.

3. I'm NOT tied to the FORMS model.

4. Testability like MVC has.

5. Friendly urls.

6. Access to the same HttpContext across threads.

7. Designer support.

8. The ability to embed and use views (pages, user controls) from external assemblies (built into the framework).

Good work, please keep it up and don't forget, enhancing the end developers ability to be productive AND in control is what really adds value to the .NET web technologies platform. After all, this was the premise of ASP.NET WebForms. Unfortunately, the constraints that were eventually evident were not fixed, we were just given yet another technology to learn with MVC but there is still something missing in my opinion.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, August 6, 2010 11:09 AM by kapilkoli

Really it looks very much exciting. Razor will rock.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Saturday, August 7, 2010 1:11 PM by Peter Tran

Hi Scott,

Love the Razor engine.  However, when used with Areas, VS2010 errors out when choosing the view engine.  Also, how do you solve the situation below?  I want the output to display num0, num1, & num2.

@{

   for (var i = 0; i < 3; i++)

   {

       <p>num@i</p>

   }

}

# re: Introducing ASP.NET MVC 3 (Preview 1)

Saturday, August 7, 2010 1:22 PM by Peter Tran

I figured it out.  

@{

   for (var i = 0; i < 3; i++)

   {

       <p>num@(@i)</p>

   }

}

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, August 10, 2010 7:19 AM by Josh

Hopefully you guys will manage to include intellisense support for razor in preview 2 :)

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, August 10, 2010 3:36 PM by Roger Hendriks

Cool new features!! I also like the new model validation options. It would be perfect if the annotations,  inter atribute and inter object rules could be defined in a consistent way in the designer and then generated to code.  Or even dynamically evalute linq expressions or wwf rules.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, August 12, 2010 9:48 AM by dennismachel

good stuff!!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, August 13, 2010 12:28 AM by Hanumanth

Hi, Will you be fixing [ValidateInput(false)] to work with the new ASP.NET 4 input validation pipeline? Currently ValidateInput(false) is broken unless you set <httpRuntime requestValidationMode="2.0" />

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 15, 2010 10:30 AM by ASIphoenix

Great job. Razor and MVC3 appears it will be a great.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 15, 2010 1:23 PM by Juanfra

Hello, I really like the new Razor engine, but I have a question, how can I import a namespace from inside a view??

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 15, 2010 1:47 PM by Christopher Deutsch

Just upgraded an MVC2 app. Painful only begins to describe the experience. I wish dependency injection would just be added to MVC. There are too many options and too many out of date tutorials on it. If I wanted this kind of painful experience I'd use an open source stack. :( I spend more time trying to get that working then I do programming. Major hold up to getting my company to switch from WebForms. I like the direction you guys are going but I really don't want a million ways to do something. Give me a default one and allow for it to be replaced like you usually do.

I'll probably be doing a blog post about getting my app upgraded. Until then ping me if you get these errors:

No parameterless constructor defined for this object.

Downloading the source to both Ninject and Ninject.Web.Mvc, upgrading them to .NET 4.0 and then recompiling is what worked for me. I couldn't get the NinjectServiceLocator in the sample provided to work. So I stuck with inheriting NinjectHttpApplication in global.asax.cs

# re: Introducing ASP.NET MVC 3 (Preview 1)

Monday, August 16, 2010 10:26 AM by ScottGu

@Christopher,

>>>>>>> Just upgraded an MVC2 app. Painful only begins to describe the experience. I wish dependency injection would just be added to MVC. There are too many options and too many out of date tutorials on it. If I wanted this kind of painful experience I'd use an open source stack. :( I spend more time trying to get that working then I do programming. Major hold up to getting my company to switch from WebForms. I like the direction you guys are going but I really don't want a million ways to do something. Give me a default one and allow for it to be replaced like you usually do.

You shouldn't have had to-do much to upgrade your application. What issue are you seeing?

For future reference, you can use this tool to upgrade apps automatically: weblogs.asp.net/.../migrating-asp-net-mvc-2-applications-to-asp-net-mvc-3-preview-1.aspx

We'll have better upgrade support built-into the box with later previews.

Hope this helps,

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, August 18, 2010 8:52 AM by frw

I recently came across something weird when trying to globalize an asp.net mvc 3 preview 1 application. Does this version not support Data Annotations from .NET 4.0? It seems like the DisplayAttribute is not being localized properly ( only using english resource file ). See further information here

stackoverflow.com/.../localizing-the-fields-attributes-on-the-accountmodel-for-asp-net-mvc

will there be a future package like there was for ASP.NET MVC 2 whereas you could do:

ModelMetadataProviders.Current = new DataAnnotations4ModelMetadataProvider();

DataAnnotations4ModelValidatorProvider.RegisterProvider();

To solve that problem?

Thanks

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, August 18, 2010 12:52 PM by Daniel Steigerwald

Hi Scott,

I wonder what is the reason to not to have REST URL?

Instead of: /Store/UpdateProduct/ post

This: /store/product put

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, August 18, 2010 2:40 PM by Phil Strong

I'm having issue after using the converter.  My strongly typed views beleive their models are of type object and not the class passed in. Getting

'object' does not contain a definition for ...

Anyone else?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, August 19, 2010 7:51 AM by Feng

Any plan to add support for localization (similar to implicit localization in WebForm)/globalization, and theme?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, August 19, 2010 7:53 AM by Feng

Any plan to add support for localization (similar to implicit localization in WebForm)/globalization and theme?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, August 19, 2010 7:55 PM by Alfred

Does the integrated DI support result in an abstraction of HttpContext (such as Request, Session, and Form )from the Controller?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 22, 2010 4:09 AM by Tyler

This all looks really great!  My most desired feature here, is to please allow the razor view engine to receive multiple variables, instead of just one called "Model".  So, for example, in my controller I could say:  

List<Category> cats = Categories.find(all);

List<Product> prods = Products.find(all);

Then, in the view, I would have two variables, cat & prod, that could be referenced like so:

@cats List<Category>

@prods List<Product>

Not being able to access variables in the view that are created in the model creates a feeling of isolation inside the view, as though its not an actual part of the app, but rather an add-on.  Maybe this could be accomplished through some metadata in the controller that would mark variables as being available in the view like so:

[ViewAccessible]

List<Category> cats = Categories.find(all);

[ViewAccessible]

List<Product> prods = Products.find(all);

Then, the variables wouldn't even need to be re-declared in the view, but they would just be directly accessible by name.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 22, 2010 10:45 PM by ScottGu

@Tyler,

>>>>>>> This all looks really great!  My most desired feature here, is to please allow the razor view engine to receive multiple variables, instead of just one called "Model".

Unfortunately this is a little hard to do - since C#/VB doesn't currently allow dynamic properties except by referencing a variable of type dynamic.  That is why you can do @View.Cats and @View.Prods within the razor view template, but not just @Cats and @Prods.

Sorry!

Scott

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, August 24, 2010 2:27 AM by Alex

>> his all looks really great!  My most desired feature here, is to please allow the razor view engine to receive multiple variables, instead of just one called "Model".

Yeah, I second that. In ASP.NET WebForms you can easily pass several variables to the view.

Here we have to create an enormous amount of ViewModels. Please implement this feature of multi variable passing!

Thanks

# re: Introducing ASP.NET MVC 3 (Preview 1)

Sunday, August 29, 2010 6:18 PM by Ben Foster

Great post Scott, I'm really excited about this release.

It would be great to see an examples of loading Razor templates from a database or separate assembly and also using the Razor parser independently - currently we are using NVelocity and object dictionaries to generate email templates - to swap this out for Razor and a dynamic view model would be sweet.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Wednesday, September 1, 2010 10:07 AM by Max From Sweden

Hello Scott, and thank you so much for this exciting stuff!!

I get an error when I try to run your sample files. The error is random and usually occurs when i run it the first time. The error message is: "Unable to complete operation. The supplied SqlConnection does not specify an initial catalog" I use VWD Express 2010. Any thoughts?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, September 2, 2010 10:22 AM by Andy LifeBrixx

Awesome work ! I've just upgraded my socialnetwork lifebrixx from MVC 1.0 to 3.0, only small tweak I had to do was remove some of the page imports I'd done as it wouldn't compile.

All up and running tho, converted any ViewData stuff to use the new dynamic ViewModel.

Look forward to getting to grips with razor.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, September 2, 2010 10:26 AM by joe

I am asking you - which software do you use to OPEN FILES on a website made in ASPX .CS MVC FRAMEWORK?  

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, September 9, 2010 12:08 AM by Jeremy

Exciting! Astonishingly good! MVC3 crosses five big items off my wish list.  Thank you.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, September 10, 2010 1:32 AM by Rick

Does this release address the clunkiness of the master pages?  When I say that, I the fact that you have to go around your elbow to have common code in your master page and to pass that data from the db to the master page and not have to do it in every single controller action.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, September 10, 2010 12:12 PM by Ben

Looks great!

Question for you: Currently there is an issue if I have defined a custom validation attribute and I set AllowMultiple = true. This allows me to use the same attribute (with different parameter values) for server-side validation. But the client-side validation code isn't generated properly. Only one entry (the last of the ones defined for a Field) is sent to the client (in the "Fields" array as part of the mvcClientValidationMetadata array).

I'm hoping this gets fixed in MVC 3 (or before).

Thanks!

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, September 16, 2010 1:44 AM by Doss

Hi, Is there any plan to come up with a sample Multi Tenant application using MVC3?

# re: Introducing ASP.NET MVC 3 (Preview 1)

Thursday, September 16, 2010 12:00 PM by Martin

How about this Scott -->

Introduce a convention for adding extra .css and .js files to a view.

whereby you would just do something like this at the top of your View.

@Css.Add("jquery-ui.smoothness","tiny-mce");

@Js.Add("jquery-ui","editor/tiny-mce");

Then these extra files could be dynamically inserted at the bottom of the head section without having to create an extra ContentPlaceHolder in the head section of the master template or implement custom code to manage these extra additions. The convention would have to be where the css and Javascript is located in the directory structure similar to the Views convention.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Friday, September 17, 2010 5:14 AM by Danno

Great Work so far -> good to see all the new improvements coming in to play.

I think certain htmlhelpers could do with improving. Definitely dropdownlists - these take too long to set up at the moment for what they are as the IEnumerable<SelectListItem> needs setting up first which can get out of hand for lots of dropdowns. Also an easier way of handling checkboxlists would be good.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Monday, September 20, 2010 9:20 AM by Orion

Hi, I dont know if some1 asked before, but what im looking forward the most is Caching, cos Caching in mvc 2 is VERY weak.

# re: Introducing ASP.NET MVC 3 (Preview 1)

Tuesday, September 21, 2010 5:19 PM by Scott Moore

I can't seem to find any information on what's in the MVC 3 futures dll, anyone know?