In my _Layout page, I have added following code before @RenderBody()
- @if (Session["UserID"].ToString() != "" || Session["UserID"]!=null)
- {
- if (Session["RoleID"].ToString() == "2")
- {
- //menus here
- }
- }
- else
- {
- Response.Redirect("~/Account/login");
- }
I downt want to call @RenderBody() is Session["UserID"] is empty.
please help me out

Rajanikant HawaldarRank #110 · 20.2K reputationPosted Apr 30, 2020, 10:52 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 30, 2020, 10:44 PM EDT
Hi,
Your condition is ||. It should be && condition. And ideal way to check null first and rest of condition check later.