Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to have a side bar that it`s options and menus could be differ depend on witch user is logged in. the side bar should load for the first time in the div tag of the layout and remain unchanged until the user has not logged out. how can i do that? i mean how can i dynamically load a section for the first time as a part of layout and do not touch it after that (using RAZOR engine)?
thanks in advance
Posted

What you are looking for is @Html.RenderAction() with an action that does a return PartialView();

In the action, you can test for the user/role and determine what to populate the model with or even which view to return. Create corresponding partial views that render the content as appropriate, if the user is logged in.

I would also suggest reading through the ASP.NET MVC best practices[^] that Kazi Manzur has posted, including the bits on authentication filters.

Cheers.
 
Share this answer
 
hi. thanks to your answer but what happen when user click another link and redirected to another page of my application? the answer is:
1) my layout should re render that section and
2) resend the section to the client and
3) obviously side bar changed (closed tabs and opened tabs in sidebar will return to it`s default)
these are 3 major problem with this solution. my goal is to load this section for the first time and after that this sidebar going to be a part of the layout and does not need to render every time. can you give me another solution?
thanks again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900