Last night at the Winnipeg .NET User Group, D'Arcy Lussier presented on the ASP.NET MVC Framework. He had spoken previously at our Code Camp on it, and this presentation went into more detail. It was a good intro to many of what MVC is and why it is going to be useful and (relatively) easy to build websites. I have learned about MVC some time ago and wanted to learn more, but needed several things to do it:
-
Visual Studio 2008 (got a full version at the Heroes Happen Here event)
-
An idea of what to do to learn it
-
Time
That last one was the hard part. But today I was home sick from work so decided to play with it a little. And what project did I choose? Well, my company does some public-facing websites for our clients and we are in the midst of reskinning one. As a Project Manager, my role is not to build the applications anymore but to make sure the work gets done. After 10 years (5 years at my current company) of doing such sites and applications, it is easier said than done. However, this is still how I can do the work AND learn MVC: take the project and convert it at home to an MVC app. Now, I know I won't have all the bells and whistles right off the hop, and my CSS skills need some DEFINITE work, but the main functionality should be fairly straightforward. After playing with it for several hours, here is what I have found so far:
Routing Table
Love it. Since I knew what the URL structure would be up front, this was relatively simple to do. There are some things that others out there may know that I do not, though, so here are some issues I have:
I have multiple levels that need analysis. Here is an example of a URL (not the actual URL being used but something to give the same format so it's not a client URL):
http://localhost/books/2008/scifi/home
http://localhost/books/2007/fantasy/home
I use the following route table with it:
routes.Add(new Route("{controller}/2008/scifi/{action}/{id}", new MvcRouteHandler()) {
Defaults = new RouteValueDictionary(new { controller = "Books", action = "Home", id = "" }),
});
routes.Add(new Route("{controller}/2007/fantasy/{action}/{id}", new MvcRouteHandler()) {
Defaults = new RouteValueDictionary(new { controller = "Books", action = "Home", id = "" }),
});
Now, I could use "id" but I still need other sub-pages for similar items and that's what I would use the id for. Now I know I can strip out the other variables with a Request object call in code, but is there an easier way to create the route table, or do I have to have more hard-coded values such as above as I progress? (Suggestions are greatly appreciated.)
Apart from that, the route table is working really well. I still have to fix a 404 if it's not found at all, but I can always go in there and fix that later (already saw a blog post elsewhere on that). But so far, got the controllers all worked out, the route table, and the base ASPX pages and the primary master page (still have to add in the nested master pages). Not bad for a first attempt at playing with it (more than just watching webcasts and reading blog posts), if I do say so myself...
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5