Connecting Tech Pros Worldwide Help | Site Map

how to use Castle Windsor with ASP.NET webforms?

ssnaik84's Avatar
Member
 
Join Date: Aug 2009
Location: Bengaluru, India
Posts: 119
#1: Sep 29 '09
Hello,

I googled for Castle Windsor usage, but, I got examples of ASP.NET MVC / MonoRail.

Can you please explain how to use Castle Windsor with ASP.NET webforms?


Thanks in Adv.

Swapnil
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#2: Sep 29 '09

re: how to use Castle Windsor with ASP.NET webforms?


Hi Swapnil,

I just looked into the Castle Windsor project and discovered that it is supposed to be used in systems that are designed using the Inversion of Control principle.

The Inversion of Control principle is pretty cool. It lets you uncouple the application layers so that they aren't dependent on one another.

Model View Controller (MVC) operates with the same principle...it lets you uncouple the different application layers so that each individual part can do it's own thing without depending on the other layers.

ASP.NET web forms won't let you do this. The applications layers are much more tightly bound and it's....well, not as clean as MVC (or the Inversion Control Principle).

I don't know very much about the third party controls that Castle Windsor produces, but reading their intro page leads me to believe that it will be very difficult to use their controls in a regular ASP.NET web forms application.

Upgrade to MVC.
I think you'll be pleasantly surprised :)
I know I was when I first started checking it out....I haven't had a lot of experience with MVC but I know that it is a lot better than regular ASP.NET web forms because it uncouples the different application layers so nicely.

-Frinny
ssnaik84's Avatar
Member
 
Join Date: Aug 2009
Location: Bengaluru, India
Posts: 119
#3: Sep 29 '09

re: how to use Castle Windsor with ASP.NET webforms?


Hi Frinny..

I'd already given a try to MonoRail and ASP.NET MVC...
they are cool.. personally, i like MonoRail.. and i'm a big fan of Ayende
but problem is.. we cant use server controls. we have to work in classic asp age... regular asp.net development is much faster.
that is why.. i'm searching for golden middle..

Do you know about MVP (ASP.NET Web Forms Model-View-Presenter)?
Can you guide me on this topic?

Thanks!!!
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#4: Sep 29 '09

re: how to use Castle Windsor with ASP.NET webforms?


Sorry but I don't know anything about MVP.

Finding a middle ground for MVC and web forms is probably going to be pretty hard.

I personally don't like the idea of using controls in MVC because of the nature of controls....

Controls sit between different application layers. This means that MVC's desired uncoupling design will be lost. This means that the nice, neat and tidy, testable units will not be available...that is a huge thing to lose. Not only that but controls have their own events, and a lot of the time handle their own events too. They gobble up events instead of letting them be handled by the layer/class that should be handling it. Again, making them less testable than the tidy-testable units that you'll have when you use pure MVC.

I know that we've been spoiled by .NET controls...MS came along and gave us a bunch of tools that helped us to quickly develop things.

But these controls are very bulky (depending on viewstate etc), and a lot of them are so out of date that you can't do anything with them client side (don't get me started on this issue... I almost gave up on .NET once because it).

MS has stopped evolving these controls and hasn't kept them up to date with the new web standards of today.

Controls are not your answer....if you start using them you're going to be working backwards not forwards.

I should probably tell you that I too am dependent on controls. I develop server controls all the time to take care of things in my web forms applications. But I understand the their true, horrible, nature. I see how they are not the best design and sometimes I feel dirty/bogged down using them. I understand that MVC is hands-down better and would recommend it's design to anyone as apposed to web forms and controls.

I haven't yet taken the plunge into MVC completely but I'm extremely interested in it because it doesn't use controls. I know that when I do start using MVC it's going to require me to adopt a completely new and different mindset when it comes to developing web applications. I'm very excited about it...I'm hoping to start using it within the next couple of months.

I'm not sure what to suggest because I'm not quite at the stage you are with respect to developing using things like MVC or MVP.

But what I do know is that controls are absolutely the wrong things to become dependent on. They are bulky, less testable because they sit across application layers, outdated and not properly maintained so tend to be behind web standards....I could go on about the evil nature of these things but I don't think you'd truly understand unless you had tried extending upon these outdated beasts.

Stick with the "new-old-asp" style...it may feel like you're moving backwards but you are actually moving forward...keep your code clean, and in testable separate layers by using MVC and leave controls to decay as the dinosaurs that they are.

-Frinny

PS if you insist on using controls I'll still try to help you out...but I've never used them in MVC and don't know how helpful I'll actually be.
ssnaik84's Avatar
Member
 
Join Date: Aug 2009
Location: Bengaluru, India
Posts: 119
#5: Sep 30 '09

re: how to use Castle Windsor with ASP.NET webforms?


Quote:
I know that we've been spoiled by .NET controls...
Yes.. I am!!! that's why i couldn't make my mindset to switch @MVC pattern.

well.. I'm really.. heartily thankful to you for such a great guidance.
now i'll again surely take a look at ASP.NET MVC.
thanks.. thanks a million :)

btw.. you must be knowing but MvcContrib is a very good initiative towards ASP.NET MVC enhancement

-- Swapnil
Reply