我想更改应用程序的布局,在我的应用程序中有两种类型的用户Admin和Member,来自admin的成员可以登录。我想从管理员登录成员时将布局更改为成员。 这是我的代码
public ActionResult UserLogin(string email, int type)
{
#region SignOut Admin First
//signout First
if (Session["id"] != null)
{
UserLogBL ul = new UserLogBL();
UserLog lg = ul.GetByID(Convert.ToInt32(Session["id"]));
lg.logout = Convert.ToDateTime(System.DateTime.Now.ToLongTimeString());
ul.Update(lg);
}
Session.Clear();
Session.Abandon();
LmsSession.Abandon();
FormsAuthentication.SignOut();
#endregion
//getting user detail
LearnerBL learnerBL = new LearnerBL();
int id = learnerBL.GetIdBYName(email);
Learner learner = learnerBL.GetByID(id);
if (learner != null)
{
String role = LoginUser(learner);
if (string.Equals(role.ToLower(), "admin"))
return RedirectToAction("Index", "AdminDashboard");
return RedirectToAction("Index", "LearnerMyLearning");
}
return RedirectToAction("Login", "Account");
}
答案 0 :(得分:0)
在相应的视图中,您可以设置视图应使用的布局。
@Layout="~/Views/Shared/LayoutNameHere.cshtml"