The ASP.NET MVC currently stores all route information in global.asax. One of the first things I did when I began playing with the CTP was moving the routing rules into a HTTPModule.
However, I do not believe that configuration should ever be stored inside a compiled code file.
I blogged yesterday about my difficulty in building a dynamic route builder due to the Route object only accepting an anonymous type for the "defaults" property.
However, with the help of Eilon Lipton (One of the principle developers behind ASP.NET MVC), I was able to circumvent this limitation by using a custom class that inherited from CustomTypeDescriptor at the cost of having to write a lot of boilerplate code.
The final product? A simple HTTPModule that allows you to place your routing rules in web.config where they belong.
The binary and full source are available on the RouteBuilder CodePlex page.
Download and check it out. There are full (simple) installation and usage instructions in the zip file.
Huge thanks to Eilon for promptly answering my questions. This speaks volumes about Microsoft's dedication to the development community.
Please let me know if you have any issues using it, or how it can be improved.
Thursday, December 13, 2007
Subscribe to:
Post Comments (Atom)
7 comments:
Damn nice work, and also thumbs up to Eilon for helping so fast...
Is the web.config really an apprioriate place? It already is big in a lot of applications. I would like it very much if it was configurable to some kind of xml file, instead of the web.config.
But like poulrh said: Damn nice work ;)
Very nice. Seems like this would be a nice fit for the MVC Contrib project.
Would you mind contributing that to the MvcContrib project? - Jeffrey Palermo
THANK YOU... It's amazing something like this doesn't already exist in the MVC Framework to begin with. :o
But you've saved me from writing a bunch of code. For that, I tip my hat!
Thank u good work The key is to use something that may be new to you: control adapters. These are little chunks of logic that you add to your web site to effectively "adapt" an Malayalam search engine ASP.NET control to render the HTML you prefer. The ASP.NET 2.0 CSS Friendly Control Adapters kit
Is the web.config really an apprioriate place? It already is big in a lot of applications. I would like it very much if it was configurable to some kind of xml file, instead of the web.config.
---------------
Have you heard anything about partial web.config files? It would do the trick perfectly.
Post a Comment