Dynamic change ViewStart layout path in MVC 3

前端 未结 4 649
不知归路
不知归路 2021-02-10 07:56

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:20

    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

提交回复
热议问题