Can I create a controller for layout in asp.net mvc4? -
i have menu , used cookie in order set menu selected refreshing. menu common classes, put in _layout.cshtml, same time want controller layout because there function set menu highlight. can create controller this?
yes, can call @html.action
or @hmtl.renderaction
invoke controller view. borders on mixing of concerns, view actively calling controller.
the better approach pass appropriate data view part of view model.
but same time want controller layout because there function set menu highlight.
if doing basic highlighting current page, there may simpler solution. put current page id viewbag
, retrieve value in main _layout file , use select appropriate item.
Comments
Post a Comment