Why should I use inline coding for ASP.NET MVC development?

I have looked at some ASP.NET MVC examples and they all use built-in coding method.

Is there a big reason to use this method and ignore my preferred code behind method?

+1


source to share


3 answers


Nice quote from Derek Whittker. I couldn't, but better than myself.

Also reference the identical Q on SO



"In standard WebForms Asp.net, developing CodeBehind meant acting like a page controller, but the years have become a dumping ground for all sorts of evil code (ie business logic). This disgusting, ugly code that gave (to part of) WebForms is bad image From continuing to use your code in MVC, what you really do is the old nasty technique and applying it to the new framework and in turn is one of the big advantages of MVC.

Part of the beauty of the MVC pattern (note that I said pattern, not framework) is that it helps Separate Problems by pushing logic out of your view and into your controllers. "

+3


source


I think the main reason for this is that there really shouldn't be a lot of logic in there, as it's just view related logic. When there isn't much logic I find it reads better using an inline method. However, if there was a view with a lot of loops, and using code like that behind it is definitely a viable option in my opinion.



+1


source


In Scott Gu's recent blog on MVC Release Candidate, they have views that have no code by default, which might be the reason you don't see this in the samples.

0


source







All Articles