views:

45

answers:

1

I have been reading on MVC and I created some db-driven pet projects with it and I am very pleased with the shift from WebForms.

However, I have a bit of a limitation that holds me back with WebForms and I was wondering if you could help me with it.

I work for a Web CMS company as a Consultant, therefore all websites (public sites, intranets, extranets, you name it) are based on the CMS software from my company (which should remain nameless).

One of the features that the sales guys like to pitch about our software is its "friendly" urls. Baiscally all data is stored and structured within the CMS like a file system. Then when you point your browser to http://mywebsite.com/about the CMS will return the contents from the item stored under the root with the name "about".

Each item also has a (interchangeable) template registration which is the physical location of the file that is going to display the contents of it (an .aspx page). Just like the "Views" on MVC.

To handle the friendly URLs I have to add a HTTP Handler as follows:

<add verb="*" path="*" 
     type="Cms.ASPDelivery.HttpRequestHandlerFactory, CmsDelivery" />

That will take care of the friendly URLs and will do the mapping between contents and views.

In an architectural way you could see that just like MVC. The data is stored in the CMS, the presentation is independent of the data, and the handler will be the Controller.

But when it comes down to coding in itself, it is the same old Webforms spagetti.

So, my question is: Do you see any way that I could use both MVC and my CMS' Http Handler?

+1  A: 

It depends on the concrete Implementation of the HttpHandler but in most cases it is possible. You have to add the MVC UrlRoutingModule and setup the MVC. I use MVC in a CMS environment with friendly url-s. The CMS is called EPiServer and from what you described it has pretty much the same functionality. I use ASP.NET MVC for the template pages. The path to the physical pages is actually handled by controllers' actions. It works fine and with some tweaking I can say that it is a lot better than WebFroms especially if you develop custom web applications.

Branislav Abadjimarinov
I added a comment on your blog at http://www.abadjimarinov.net/blog/2009/10/27/AspdotNETMvcDefaultRouteProblem.xhtml
pablo