Thursday, May 12, 2011

When you create an MVC web project in Visual Studio there is already a default folder structure convention. Like the image below.

I'm new to ASP.net MVC, but I've been developing .net applications for over 4 years now. The problem is I never liked the default folder structure of the asp.net mvc project and certainly this is now how I want my web project to be implemented. There are other things need to be considered, for instance the decoupling of components, for example if I want my controllers to be on a different assembly and so as my models.

Now when you move the files from the Views folder into the root directory, your web application will not run, because by design the default ViewEngine will always look up at this directory ~/Views to find your controls, master pages and views.

I want my mvc project to be structured something like this.

You could see, I created another project which holds the web controllers and the views are transferred to the root folder instead of ~/Views.

~/Home - Home folder (used to be ~/Views/Home)
~/Account - Acount (used to be ~/Views/Account)
~/Controls - Logon Control was transffered here instead of ~/Viws/Shared/

and the Site.Master and the Error.aspx was transferred to the ~/ (root)

With regards to the controllers HomeController and AccountController they were just transferred to another assembly but their namespaces are intact.

In order for this to work we need to customize a ViewEngine so we could locate our views/partial views.

ViewLocationFormats - where to find the views
PartialViewLocationFormats - where to find the controls
MasterLocationFormats - where to find the master pages

You could see in the implementation that the location of the views, partials views and master pages are hard coded, it would be best to make it dynamic, maybe put it in a config file or a database. And also its better if you could also put your customized ViewEngine class in a different assembly for reusability.

After you have a customized ViewEngine all you have to do is to add your customized ViewEngine to asp.net MVCs ViewEngine Collection.

On the application start method of your global.asax add the following line of code

Moalboal - Summer 2011

This is a late post, these photos were taken last March 27 2011 in Moalboal. Moalboal is a town in Cebu South famous for its beaches and diving spots. Too bad I didn't have any underwater camera housing, to provide underwater photos.

Wednesday, May 11, 2011

Does this mean no more free video and skype to skype calls? haha. I have to mention $8.5 billion?.

For non-windows platforms, "Microsoft will continue to invest in and support Skype clients on non-Microsoft platforms." quoted from the link above. I guess it's still ok. For now.

Also from the link above, "Skype will support Microsoft devices like Xbox and Kinect, Windows Phone and a wide array of Windows devices, and Microsoft will connect Skype users with Lync, Outlook, Xbox Live and other communities." I believe those are good areas to integrate skype into.