1

I reviewed some examples about MVC ASP.NET and all of them use the inline coding method.

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

3 Answers 3

3

A nice quote from Derek Whittacker. Couldn't but it better myself

Also refer to this identical Q on SO

"In standard Asp.net WebForms development the CodeBehind was meant to act as a page controller, but over the years it has turned more into a dumping ground for all sorts of evil code (ie business logic). It is this nasty, ugly code that has given (in part) WebForms a bad image. By continuing to use your code behind in MVC all you are really doing is taking an old nasty technique and applying it to new framework and in turn removing one of the great advantages of MVC.

Part of the beauty of the MVC pattern (notice I said pattern, not framework) is that it helps to enforce Separations of Concerns by pushing logic out of your view and into your controllers."

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, what's you idea about this question: stackoverflow.com/questions/390693/… , I am so confused, because this question got 21 plus votes to now but I got -4 on the same.
1

I think the main reason for this is that there really shouldn't be much logic there since it's only logic related to the view. When there's not much logic my opinion is that it reads better using the inline method. However if there was a view with lot's of loops and such using the code behind is certainly a viable option in my opinion.

Comments

0

In Scott Gu's recent blog about the MVC Release Candidate, they are having views not have code behind by default, which may be a reason you don't see that in samples.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.