background preloader

Aspnetmvc

Facebook Twitter

13 ASP.NET MVC extensibility points you have to know. One of the main design principles ASP.NET MVC has been designed with is extensibility. Everything (or most of) in the processing pipeline is replaceable so, if you don’t like the conventions (or lack of them) that ASP.NET MVC uses, you can create your own services to support your conventions and inject them into the main pipeline. In this post I’m going to show 13 extensibility points that every ASP.NET MVC developer should know, starting from the beginning of the pipeline and going forward till the rendering of the view. 1. RouteConstraint Usually you could put some constrains on url parameters using regular expressions, but if your constrains depend on something that is not only about the single parameter, you can implement the ’s method and put your validation logic in it. One example of this is the validation of a date: imagine an url that has year, month and date on different url tokens, and you want to be able to validate that the three parts make a valid date. 2. 3. 4. 5. 6. 7. 8.

Catharsis - Home. MVC Preview 5 and Form Posting Scenarios - ScottGu's Blog. This past Thursday the ASP.NET MVC feature team published a new "Preview 5" release of the ASP.NET MVC framework. You can download the new release here. This "Preview 5" release works with both .NET 3.5 and the recently released .NET 3.5 SP1. It can also now be used with both Visual Studio 2008 as well as (the free) Visual Web Developer 2008 Express SP1 edition (which now supports both class library and web application projects). Preview 5 includes a bunch of new features and refinements (these build on the additions in "Preview 4"). You can read detailed "Preview 5" release notes that cover changes/additions here. Basic Form Post with a Web MVC Pattern Let's look at a simple form post scenario - adding a new product to a products database: The page above is returned when a user navigates to the "/Products/Create" URL in our application.

The markup above is standard HTML. The "Create" action method above is responsible for returning an html view that displays our initial empty form. Model Binders in ASP.NET MVC. Hot off the presses, and new to ASP.NET MVC (Preview 5) is an awesome capability that (in my opinion) revolutionizes the way we design web applications. This feature is being touted (by me) as "the ViewState for MVC". First, the Challenge A common challenge of web applications is passing complex types and (more difficultly) stateful objects from one page to another. This difficulty is due to the disconnected nature of the web. There have been many attempts to solve this problem (sessions, ViewState, etc), but ASP.NET MVC's new "Model Binders" functionality definitely takes the gold medal for being the cleanest, simplest and most powerful.

We're going to build a couple of simple MVC pages, one that display a list of customers and the other displays their address details. What Are the Benefits? ASP.NET MVC Model Binders give you the following benefits: Complete control over the deserialization of complex types passed into your Action methods. // ... other properties ... return customer; } Maarten Balliauw {blog} - Building an ASP.NET MVC sitemap provid. Warning! A new version of the source code provided in this post is available here. Use this blog post as reference only. Yes, it has been a while since my last post.

A nice vacation to Austria, some work to catch up, ... If you have been using the ASP.NET MVC framework, you possibly have been searching for something like the classic ASP.NET sitemap. Feel free to download the sample code. The base concept of this class is based on someone else's version which supports dynamic nodes, populated by code instead of XML. The concept What I would like, is having a web.sitemap file which looks like the following: [code:c#] [/code] That's right: regular siteMapNodes, but also mvcSiteMapNodes! Each mvcSiteMapNode is structured like this: Implementing it Two options for this one...

This MvcSiteMapProvider class will have to do some things: If you want to check the full source code, feel free to download it. MvcSiteMapNode First things first! #region Properties #endregion #region Constructor return smNode;} Foundations of Programming - Learning Application - Karl Seguin. If you’re anything like me, you probably learn a lot better by going through code rather than reading books. I’m happy to release the Foundations of Programming Learning Application – it’s a complete solution meant to show what was covered in the Foundations series. It’s a Visual Studio 2008 solution. You can download it here. It should require no configuration (my fingers are crossed on that one) and ought to just run out of the box. There are comments sprinkled all over to help explain things or provide some insight. No doubt there’ll be typos, since I’m nothing without word.

(you can grab the free ebook from: What is it? The web application mostly shows a read-only view of the data. Of course, there’s a project full of unit tests as well.