In ASP.NET MVC 3 if you define a section in a view that isn’t defined in the layout you get an exception thrown. Is there a way mark the section option from the view ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t render a section in a view that is not defined in the layout.
You can assume like layout is an abstract class and view is a concrete implementation. The section defined in layouts are nothing but abstract methods that will be implemented in views.
So adding a section in view that is not defined in layout is kind of implementing an abstract method that even not exists. And if you define a section in a view it is like adding an abstract method to a concrete class and that changes the view into a layout. Hope this answers your question.