Dynamic change ViewStart layout path in MVC 3

前端 未结 4 2231
囚心锁ツ
囚心锁ツ 2021-02-10 07:42

In my MVC project has 2 Areas which is Admin and Client and I need to dynamic config Layout for Client side, In _ViewStart (in client) file will set layout for all of client pag

4条回答
  •  囚心锁ツ
    2021-02-10 08:18

    Your question has not enough information to give you a complete code sample.

    But basicly you can do this

    if (InsertIsAdminLogicHere) {
         Layout = "~/Views/Shared/_AdminLayout.cshtml";
    } else {
         Layout = "~/Views/Shared/_Layout.cshtml";
    }
    

    If you show us how you determine admin or not, we can provide more help.

    hope this helps

提交回复
热议问题