hi i have mvc website where i am using layout for consistant look and feel. now my menu is dynamically generated based on user role,level etc. i have put menu on layout page.when user logs in menu generated as per its role from database .when user clicks on menu it loads the currosponding view in layout, but it also refresh the layout page becouse all views have layout , so menu also gets regenerated cousing databse trip. how should i avoid menu reloading ? i dont want to use ajax to load views in layout page becouse back button doesent work and new tab loads pages without layout. please help
Asked
Active
Viewed 4,392 times
2 Answers
1
what i did is loded the pages without layout in div inside layout using ajax.and in viewstart.chtml written following
Layout = Request.IsAjaxRequest() ? null : "~/Views/Shared/_Layout.cshtml";
so when request is through link (in new window) views will come with layout page (this solved new tab problem).
2) for backbutton of browser used jquery.address plugin.

A_m0
- 974
- 2
- 17
- 45
-
i searched more than 3 hours! , for this a line code! very thank amol. – Amin Ghaderi Apr 24 '14 at 11:12
0
A common use for session variables is to store the user, and its role, level, etc. This may or may not avoid a DB round trip, depending on where you store your session. For example, an "InProc" session state (the default) is stored in memory, so access is very fast). See: Which one is better, InProc or SQL Server, for Session State mode in asp.net?
-
i think you dont get the pronlem.its not about users role levels etc its about avoiding reloading of layout page on each menu vie page to avoid reloading of dynamically generated menu each time. – A_m0 Mar 22 '13 at 17:34
-
and its definitlely not about session storage!!!! there is database function to give me user specific menu items stored in database with user role level mapping – A_m0 Mar 22 '13 at 17:39