Accidental Technologist

Entries categorized as ‘Microsoft MVC’

ASP.NET MVC Source Code Now Available – ScottGu’s Blog

March 21, 2008 · Leave a Comment

As an fan of all things MVC, today’s news of the release of the ASP.NET MVC Source Code was really good news.  I think it shows Microsoft’s continued steps toward being open source. 

Scott Guthrie was the one breaking the news and he has some details on his blog to check out.  The source was released as part of a CodePlex project and can be found as part of the ASP.NET CodePlex project, where the source can be found and downloaded.

Scott Hanselman also has a great post about his thoughts on the ASP.NET MVC source code and goes into some detail in The Weekly Source Code.  It’s really nice to see Scott spend the time pointing us to various areas of the source code.  It’s good stuff and worth the read.

In case you missed one of Scott’s earlier examination of the ASP.NET MVC Source you should also check it out.

Categories: .NET · ASP.NET · Microsoft MVC

ASP.NET MVC Framework Preview 2 – Changes for the Better

March 17, 2008 · Leave a Comment

The team providing us with the ASP.NET MVC Framework made available the 2nd preview release during the MIX08 Conference March 5-7, 2008 in Las Vegas, NV.  This release has many great changes as they team works toward an RTM maybe later in the year, but no promises were made.

I just wanted to point out some of the bigger changes in the Preview 2 release.

The ASP.NET MVC Framework can be deployed in the \bin directory of an app and work in partial trust

One of the pain-points in the current CTP of the ASP.NET MVC Framework is the framework is installed with a setup program to register it in the Global Assembly Cache (GAC), this is fine for local installations on development machines but not good when need to deploy to other systems.  Microsoft is fixing this:

Starting with this upcoming preview release we will enable applications to instead directly reference the System.Web.Mvc.dll assembly from the application’s \bin directory.  This means that no setup programs need to be run on a sever to use the ASP.NET MVC Framework – you can instead just copy your application onto a remote ASP.NET server and have it run (no registration or extra configuration steps required).

Requiring  System.Web.Mvc.dll to be in the GAC also made it unlikely to be able to use the MVC framework with shared hosting providers, the new CTP will also fix this potential problem as well:

We are also doing work to enable the ASP.NET MVC framework to run in “partial/medium trust” hosting scenarios.  This will enable you to use it with low-cost shared hosting accounts – without requiring the hosting provider to-do anything to enable it (just FTP your application up and and it will be good to run – they don’t need to install anything).

It’s unlikely anyone would have faced these issues yet, since the MVC is so new, but good to know it was thought out in advance.

Significantly enhanced routing features and infrastructure

URL routing is one of the most powerful features of the MVC framework, letting developers have infinite control over the structure of the URL’s in their applications. 

This upcoming ASP.NET MVC preview release contains even more URL routing features and enhancements.  You can now use named routes (enabling explicit referencing of route rules), use flexible routing wildcard rules (enabling custom CMS based urls), and derive and declare custom route rules (enabling scenarios like REST resources mappings, etc).

We have also factored out the URL routing infrastructure from the rest of the MVC framework with this preview, which enables us to use it for other non-MVC features in ASP.NET (including ASP.NET Dynamic Data and ASP.NET Web Forms).

Improved VS 2008 Tool Support

The initial release of the MVC framework shipped with some useful but simple templates for web projects but improvements are coming:

This upcoming ASP.NET MVC preview release will ship with improved VS 2008 integration.  This includes better project item templates, automatic project default settings, etc.  We are also adding a built-in “Test Framework” wizard that will automatically run when you create a new ASP.NET MVC Project via the File->New Project dialog.  This will enable you to easily name and wire-up a unit test project for your ASP.NET MVC application.

The Test Framework wizard will allow the developer to choose from a list of available unit testing frameworks but is pluggable to allow for additional testing frameworks to be added.

[ControllerAction] Attribute No Longer Required on Controller Action Methods

The first MVC framework required developers to use the [ControllerAction] attribute to distinguish action methods on a controller in order for it to be callable from an application.  Due to developer feedback the new release will do away with this requirement and make all public methods defined on a controller to be action methods and therefore callable.

There will be attributes available to use to make a public method a non-action method.

New Filter Attribute Support for Controllers and Action Methods

A new feature being added to the release are Filter Attributes.  Basically, these attributes are actions a developer may want to execute either before or after a controller or its action executes.

These enable you to inject code interceptors into the request of a MVC controller that can execute before and after a Controller or its Action methods execute.  This capability enables some nice encapsulation scenarios where you can package-up and re-use functionality in a clean declarative way.

HTML Helpers Built-in

Helper methods were limited in the first release of the framework, where a separate download was made available which included a bunch of HTML helper methods.  The new release will have all of the optional helper methods built-in.  Future framework updates will include ASP.NET AJAX support:

Next month we are also going to start to talk about some of the new enhancements to the client-side ASP.NET AJAX libraries we are making, as well as some of the AJAX helper methods we will build to enable it to easily integrate with ASP.NET MVC.

These were the HTML helper methods developed by Rob Conery.

Lots of Refactoring and Design Improvements

As with any public CTP of a product, the idea is to iterate and evolve the product into something people will use.  The team is making design improvements to the existing code base to allow for better extensibility.

In general the team has followed a philosophy where for all features you have three options:

  1. Use the built-in features/implementations “as-is” out of the box
  2. Slightly customize the built-in features/implementations without having to write much code
  3. Completely swap out the built-in features/implementations for custom ones

For example: you can now override the ViewEngine locator logic without having to override the ViewEngine execution logic (and vice-versa) – or alternatively swap out ViewEngines entirely.  The Controller Factory support has been extended to make it even easier to integrated with dependency injection frameworks.  Route rules are now fully extensible.  Controllers are more easily testable, etc.

This type of flexibility gives developers choices, not forcing them into doing things a certain way which can help improve the ability for developers to more quickly adopt the framework.

Downloadable ASP.NET MVC Framework Source that can be Built and Patched

Following the lead of downloadable .NET Framework source code, the team will be making the source code for the MVC framework available with the same methods.

Starting with this next preview, we are also going to make the ASP.NET MVC Framework source code downloadable as a buildable VS project solution.  This will enable you to easily view and debug the ASP.NET MVC Framework source code.  We are also going to include a license that permits you to optionally make patches to the ASP.NET MVC Framework source code in the event that you run into a bug in an application you are developing with it.

The license won’t enable you to redistribute your patched version of ASP.NET MVC (we want to avoid having multiple incompatible ASP.NET MVC versions floating around and colliding with each other).  But it will enable developers who want to get started building ASP.NET MVC applications immediately to make progress – and not have to worry about getting blocked by an interim bug that they can’t work around.

Screencasts Showing-off Features

Scott Hanselman has put out some great screencasts to show off how the ASP.NET MVC works in its current iteration.  At the time I write this there are 4 screencasts available showing increased complexity while working on the same sample code base.

Also available is Scott’s session at MIX08

Developing ASP.NET Applications Using the Model View Controller Pattern

I have taken the time to work with this Preview 2 of the ASP.NET MVC Framework and developed some simple applications, which worked wonderful.  My experience with Ruby on Rails really helps in understanding this framework.  Comparing the first CTP to this one is really a night and day difference, in my opinion.  I am looking forward to future releases and building real applications this way on .NET.

Categories: .NET · ASP.NET · Microsoft MVC

Rob Conery and team release SubSonic 2.1 Beta

February 4, 2008 · 2 Comments

subsonicsmall.png

Ron Conery, who recently joined Microsoft has somehow found time to release a new version of SubSonic, 2.1 in beta.

I have been using SubSonic since the 2.0 release and find it is a really nice OR/M tool for .NET applications. It offers some of the things I find particularly attractive in Ruby on Rails, things like Migrations.

The SubSonic 2.1 beta 1 offers so much more:

A New Query Tool

We have a new Query tool that lives happily alongside our existing one. Our goal with it was to make it as “Fluent” and “SQL-y” as possible. I wrote a post on how it works here, and updated that post here. Please refer to that until can crack out the docs which, yes now that this is my job, I will be spending a good amount of time on.

Northwind.CustomerCollection customersByCategory = new Select()
.From()
.InnerJoin()
.InnerJoin(Northwind.OrderDetail.OrderIDColumn, Northwind.Order.OrderIDColumn)
.InnerJoin(Northwind.Product.ProductIDColumn, Northwind.OrderDetail.ProductIDColumn)
.Where(“CategoryID”).IsEqualTo(5)
.ExecuteAsCollection();

SubStage

Eric and his secret little project are ready to see the light of day. I’m not sure how to categorize this thing, other than to say it’s a SubSonic Geek’s Best Friend. It’s part IDE, part Help Resource, Part Config tool, part Validator. Eric’s working up a screencast on it now (link to follow) and here are the highlights:

* Load your Web(or App).config and it will load your Database up, with settings
* Work with a GUI when setting your provider bits. Not sure what to use with that naming problem? SubStage will help.
* Validate your DB according our conventions, and see when you have problems right up front. Eric’s built in a complete validation system so if you don’t have a Primary Key on a table, you know it up front.
* View your object’s by Table or Class view. All of your naming and provider settings will be viewable when using our Class View – this way you’ll know your API before it’s generated.
* Generate your DAL using SubStage. Once you have everything set just so, generate the files then drag them from the SubStage Explorer window right into your project
* Work with your data. Eric build a frickin web server into SubStage, and wraps an AutoScaffold around your database so you can, literally, work with your data using our scaffold right there.
* Help… lots of Help. Access our API reference and Forums online, right through SubStage – we’re trying to make this easy for you… can you tell?

These features are great additions to what is already a great set of tools. I plan to post about a project I am working on using the ASP.NET MVC Framework with SubSonic handling my models. This project should be a great jump-off point for readers wanting to get into the Microsoft ASP.NET MVC Framework and not sure what to do about the back end.

Technorati Tags:

Categories: .NET · Microsoft MVC
Tagged: , ,

What I want in the Microsoft ASP.NET MVC Framework

January 27, 2008 · 2 Comments

505585_96069773Rob Conery’s recent post, Ramble: ASP.NET MVC Is A Geek Chisel started me thinking again about the Microsoft ASP.NET MVC Framework.  I develop software targeting the .NET framework as well as Ruby web applications using Ruby on Rails.   The .NET applications I manage have clients ranging from small shops to enterprise-wide complex pieces of software.  When I have a choice, I choose Ruby on Rails.  Why?  Because it is so much simpler to turn out software fast.

I have not given much thought to the MVC Framework lately after watching Scott Hanselman’s screencast on its usage.  No offense to Scott but the video left a really bad taste in my mouth.  I saw too much of the overly cumbersome things ASP.NET developers have to go through to make things line up.  Sure, you can drop a few controls on a page, hook up a database and wire-up your data bound controls, but that is not a realistic approach.

As most developers know, Microsoft has released an early CTP of the Microsoft ASP.NET MVC Framework which implements the Model-View-Controller pattern, the same pattern implemented by Ruby on Rails.

Rob’s post can be summed up here:

Chiseling a Digital David
While I was in Redmond last week I discussed this very thing (”the story” behind MVC and why it’s appealing) close to 12 times. I kept struggling with analogies and I think I found one that works for me. It might not work for you – but I’m sincerely interested to hear what you have to say in this arena. Believe me – it’s important!

As a developer you build things- just like any contractor building a house, or artist creating a work of art. Often times artists will choose not to use tools that save them time, preferring to build something that they can (literally) work with their hands so they can “feel the art inside the medium”.

In the same way that Big Z showed Cody how to shape a board (”looong, easy strokes”) – many people just want the machinery to get out of their way when building a web site so they can create their HTML how THEY want to, and use JavaScript and form tags as they see fit.

Some people see this as tedious, repetitive work – others see the process as creationary and artistic. I think they’re both right and I love how ASP, now, supports both.

I was in the conversation Scott referenced in his post about implementing a Repeater in MVC:

We need to come up with a Repeater control for folks using MVC…

We have a Repeater – it’s called a For Loop

I want to share who said that line but I’ll keep it close to my chest since it was said behind a closed door ;) .

What Do You Think?
Part of my gig with Microsoft is soliciting as much community feedback as I can. I tend to believe that ASP.NET MVC allows for much more “hands-on” type of development with extreme control over your UI (HTML/JavaScript) that allows you to create some really cool work.

Do you agree with this? If not – what’s the appeal for you? Does it frustrate you to have so many choices and if so – how can we help to provide some guidance?

I would like the ASP.NET MVC Framework to provide the ease of application creation just like Ruby on Rails.  I use Ruby on Rails often and the framework makes the life of the developer so much easier.  The key requirements for me are:

  • One of the most important aspects of Ruby on Rails to me is it’s ability to create web applications fast.  Prototyping is necessary to help aid clients or even other developers understand the interpretation of the business requirements.  It is much better to find out up-front the ideas are wrong before spending too much time coding.  Today this is difficult using ASP.NET WebForms.
  • SubSonic is great tool, integrate it in the framework but make the integration and usage dead easy.  Rails usage of ActiveRecord is very simple and is not something developers have to pay much attention to.  Creating Migrations, running them and then having the frame “just know” about them is great. 
  • Let me write my migrations and configuration files in my language of choice, C#, VB.NET or whatever. 
  • Give developers drop-dead-simple to powerful features like Scaffolding which makes creating back-end data management applications almost instantaneous and take the pain of this necessary evil.
  • Give me a default configuration so I just start pumping out new models, controllers, scaffolding or what ever I might need.   Command line or a right-click in Visual Studio’s Solution Explorer.
  • Make all view engines first-class citizens, easy integration and usage.
  • Make all back-end ORM toolkits first-class citizens; if SubSonic, NHibernate or some other ORM, make it just work with extensive configuration.

Powerful frameworks without a simple and default implementation lead to slow adoption.  It has taken most developers many years of dedicated development to pick up ASP.NET Web Forms and consider themselves experts on using it.  These developers won’t jump ship and just start using the MVC Framework if this framework has the complexities of web forms.  Ruby on Rails gives developers a default implementation, makes decisions for them so they can use the framework immediately out-of-the-box but provides great depth so it can be overridden and harness the great power of the underlying framework.  The key here is the canned or out-of-the-box implementation used as a catalyst to allow developers to create prototypes very quickly.

So, if Microsoft is looking for a story for the MVC Framework, make it drop-dead easy to create web applications.  Don’t make me work any harder than I do to create a Ruby on Rails applications and give me all the same tools the Rails team gives its developers.  I don’t really think I need to be pointing this out, it should be as obvious to other developers as it is to me.  I guess maybe not if you never used Rails before.

Technorati Tags: , ,

Categories: ASP.NET · Microsoft MVC

Microsoft Releases First CTP of their MVC Framework

December 9, 2007 · 2 Comments

The moment has finally arrived, Microsoft released their first CTP of the MVC Framework.  I am very anxious to get some time to start working with the bits they are releasing today.

I plan to get heavily into this framework and will post some tidbits of how it works, but in the meantime here are links to some interesting content from some people who know about the MVC Framework.

Scott Guthrie has a couple nice posts on using the framework from the past couple weeks:

Rob Conery, who joined Microsoft recently, also posted about his work on the MVC team:

Jeffery Palermo has been active working on the framework:

Rick Strahl provides some insight about his take on the MVC Framework:

Phil Haack was also recently hired by Microsoft and post some interesting MVC related items:

Microsoft has started an open source project on CodePlex for those wanting to contribute to the ASP.NET MVC Framework, called MVC Contrib.  Also, to get everyone started are some Quickstarts.

UPDATE: Thanks to Jeffrey Palermo for setting me straight, the MVC Contrib project was started by Jeffrey and Eric Hexter.  It is a project independent of Microsoft.

 

Technorati Tags: ,,

Categories: ASP.NET · Microsoft MVC

Now that Visual Studio 2008 is Out, Where is My MVC?

November 20, 2007 · 7 Comments

Now that Visual Studio 2008 has been released we are one step closer to having the ASP.NET MVC Framework in our hands.   This is one of the biggest pieces of Microsoft technology, in my opinion, that will change ASP.NET development for the better.

Since I don’t have the ASP.NET MVC Framework in my hands yet I can only make statements from the demos I have seen and from those lucky few that have had a chance to play with it.

So what makes having a different framework to write ASP.NET applications with besides WebForms important? 

  • One of the most important reasons to use the new MVC framework is getting rid of ViewState and ViewState management.  ViewState is one of those things that tend to creep up on you and before you know it your web page is huge and you have to start cutting down ViewState usage.  This is something developers should not have to worry about and manage, it’s just a waste of time.
  • Secondly, no more PostBack and PostBack Events.  Here we go again, something developers should not have to waste their time managing.  Frankly, having to have intimate knowledge of when to perform certain actions in various events leads to code that is hard to manage and maintain.  Unless you have this particular knowledge you may be inadvertently writing bad code.  I think this model was created to try to make web application development as close to being WinForm development as possible and make the job of the developer easier.  The intention probably wasn’t to make it harder.

What do we really gain from an MVC implementation?

  • Developers will be able to make use of the framework from static as well as dynamic languages, such as IronRuby and IronPython.   Much of the things that make Ruby on Rails so attractive can now be done in IronRuby using the MVC Framework.
  • Architecting a solution will be much easier and cleaner when we have very clear separation between the view, the controller and our models.   When developing a solution in ASP.NET using webforms we always have blurred lines between our different layers, no real distinction.
  • Testing will be so much easier with the innate ability for testing in an MVC pattern, we will not be pulling our hair out trying to perform the tests we know we should be doing.  Sure, we can and do test now but it is not the easiest of tasks.
  • We can also chose how we want to handle our views with third party support such as NVelocity, Brail or Microsoft’s flavor of view engine that will support ASP.NET.  We will have choice available to us.

We can forget about MonoRail and what that has given us.  MonoRail will find its place once the ASP.NET MVC Framework comes out.  My guess will be that it will take advantage of what Microsoft does and extend it for the better.    Hammett has some thoughts on this too.

I think Ruby on Rails has a lot of influence in the MVC Framework and for good reason, Rails is popular, Rails works and it really helps create maintainable and testable code.   I really enjoy working with Rails and because of this, I am looking forward to the MVC Framework. 

I hope the MVC team takes advantage of Rob Conery’s SubSonic project to give us things like Scaffolding and dynamically creating classes from our models.  I know LINQ will do wonders to make it happen.  I would like to add generation of controllers and models to my wish list too.

Maybe Santa will leave the MVC Framework in my stocking……..

Technorati Tags: , ,

Categories: .NET · ASP.NET · Microsoft MVC

ASP.NET MVC Framework – Demo App by Scott Guthrie vs. MonoRail and ASPView

November 14, 2007 · Leave a Comment

The talk in the blogs about the Microsoft ASP.NET MVC is gaining momentum and some interesting chatter is coming to the surface.

I posted my thoughts about the framework recently and came across a post by Scott Watermasysk as well, with his views in line with mine.  I found an interesting post today from Ken Egozi, who writes a view engine for MonoRail.  Ken plans on duplicating the effort put forth by Scott Guthrie who is creating a sample application using ASP.NET MVC Framework, but Ken will be using MonoRail and ASPView.

Ken has some great points about the adoption of the ASP.NET MVC Framework requiring .NET 3.5, where so many web hosts and companies support version 2.0 of the runtime and will they be willing to upgrade.   Ken’s solution can be run on .NET 2.0 today.

I am looking forward to comparing the results.   The types of challenges are what makes competition good for all developers and can only help make MonoRail/ASPView and the ASP.NET MVC Framework better for it.

Technorati Tags: , , , ,

Categories: .NET · ASP.NET · Microsoft MVC

The Microsoft ASP.NET MVC Framework Holds Much Promise

November 13, 2007 · 2 Comments

I have been an ASP.NET developer for a few years now and have used it successfully on many projects.  I never really liked Webforms from the perspective of good architecture with separation of concerns but it has been the generally accepted way to develop web application with ASP.NET.  Yes, I know about MonoRail now but it wasn’t a technology I was aware of back in the ASP.NET 1.0 days.

Much of my work on projects these days is from an architecture and technical lead role so I get to work with new technologies to see how they may best-fit into an application or environment.   I discovered Ruby on Rails about a year and half ago and was really awed by MVC pattern usage in the framework.   The MVC framework was not developed by 37Signals but they surely made it popular in today’s web development arena.

ModelViewControllerDiagram 

Today I write applications both in Ruby on Rails and ASP.NET C#, both have their strengths and weaknesses.   The single greatest feature from an architecture perspective, in my opinion, is the implementation of the MVC.  The greatest news I have heard coming from Redmond was the addition of an ASP.NET framework for MVC coming after Visual Studio 2008 is released.

First Look

The first opportunity I had to see the new ASP.NET MVC Framework was the presentation at ALT.NET by Scott Guthrie.  It seemed like Scott and his team had done their homework and produced something we could work with.

Scott Guthrie gives a very nice write-up on his blog on what we can expect in this new framework.  He says all the right things here:

  • Separation of concerns
  • Test-Driven Development (TDD)
  • Highly Extensible and Pluggable
  • URL Mapping to SEO and REST-friendly naming

These are things that make Rails very powerful and some of the things I really love about Rails.

It makes one wonder what we might be giving up, the ASP.NET MVC Framework is going to allow ASP.NET to keep the things that make using the rich framework pleasant.   The ASP.NET MVC Framework supports:

  • ASP.NET .ASPX and .ASCX and .Master as “View” templates.
  • Forms/windows authentication, URL authorization, membership/roles, output and data caching, session/profile state management, health monitoring, configuration system and the provider architecture.
  • We lose the post-back model (yah), actions are routed to a controller instead.
Best of Both Worlds

The ASP.NET MVC Framework is still some time off but the information released so far should make it easier for developers such as myself who write Rails applications but also write ASP.NET applications.  As an architect I can use my favorite web design pattern and use it on two platforms, giving me choice.

It will be easier becoming an expert on a pattern such as MVC and apply it to both Rails and now…ASP.NET.  This will be very good.

Mads Kristensen had an interesting post about the Dangers of the ASP.NET MVC Framework.  Mads states the introduction of the MVC Framework could divide the development community in a negative way.  I agree the community may split a bit but I don’t think it will be a bad thing as those entrenched in ASP.NET Webforms will continue to use them.  I will continue to use them for existing applications already running on a code base committed to Webforms.  There will be people who move to MVC either because they have used Rails or MonoRail and want to give it a try or are curious about the whole hoopla about MVC.  Webforms has a solid base and will be improved and supported, Microsoft just sees an opportunity here and is taking advantage of it for the better of ASP.NET.

The Result

So who knows where this journey will take us but I know Microsoft is not stupid and they follow what is popular and working well.  I think Rails and Monorail had great influence in creating this framework.

The framework is getting closer to being released as a CTP, as evidenced by Scott Guthrie’s great example on creating a website using the framework, part 1 of many.  I don’t know how he finds time to produce such great content but he does.

My hope is being able to have one architecture (MVC) but have two frameworks, Rails and ASP.NET MVC to chose from to solve my client problems.  I think Microsoft has taken the right approach and my hopes will be realized.

 

Technorati Tags: , ,

Categories: .NET · ASP.NET · Microsoft MVC