I have a question regarding ASP sections and partial views.
What ser the benefit of using one over another?
Because if I have a menu, i guest that it could be both as a section, but also as a partial view.
So what is the difference?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
A partial view is used when you have some view component (optionally with it's own model) that is used in more than one place, or is better separated in to a separate file (for readability, for example).
A section is placed in a master page, and allows individual views to populate those areas - they can mandatory or optional. There aren't really pro's and con's in a comparison between the two, since they serve different purposes.
For your menu example, you may have some mark-up that builds a menu (from a collection) which you would want to to use in many places, then a partial view would be the best option.
If you have a single menu on a page, whose contents change based on the page, then you might use a section to require that the view populates the menu (you may use a partial to populate that menu section too).
A partial view works well with Model Binding. You can "type-bind" a partial view so that it will "bind" to the model provided.
A Section is basically like a "placeholder" or "literal" which will just output whatever code is placed within the region in it's appropriate location defined in the "parent".
Generally, I use sections for various ad-hoc script requirements, or CSS, and partial views for DOM elements like formatting (you could use extensions too) / menus / navigation, etc... same idea as the old ".ascx" controls.
Partial views do not respect section declarations (by design) and therefor cannot be used.