Please see the image below

As you can see I have a master page Design.master and the code behind it that is called Design.master.cs.
I am simply trying to get my page to redirect to dashboard.aspx when the user is not logged it, but no matter what I try I can’t get it do it.
I want to be able to access the value of the public variable redirect, which is set in the code behind and access it from the Design.master code.
So that I can check the variable and put the Response.redirect() code in the Design.master page.
Unless you know how to get the Redirect to work from the Design.master.cs code?
Please help 🙁 It’s driving me INSANE!
Updated image

Design.master code:
<%@ Master Language="C#" CodeBehind="~/Design.master.cs" AutoEventWireup="true" %>
<%
Response.Redirect("default.aspx", true);
%>
<!DOCTYPE html>
<html>
<head>
<title>Portal</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="portal_script.js" type="text/javascript"></script>
</head>
<body>
<div id="main_wrapper">
<div id="header_top_wrapper">
<div id="header_top">
<img src="images/design/logo_small.png" id="logo_top" />
<a href="basket.aspx">
<div id="basket_top_link">
<div>Order Basket</div>
</div>
</a>
</div>
</div>
<div id="header_breadcrumb_wrapper">
<div id="header_breadcrumb"></div>
</div>
<div id="content_wrapper">
<div id="content">
<div id="side_menu">
<div id="customer_info">
<asp:ContentPlaceHolder id="CustomerInfo" runat="server">
</asp:ContentPlaceHolder>
</div>
<a href="dashboard.aspx"><div class="side_menu_item">
<div class="item_title">View Orders</div>
<div class="item_description">View your outstanding orders</div>
</div></a>
<a href="search.aspx"><div class="side_menu_item">
<div class="item_title">Product Search</div>
<div class="item_description">Search products and view stock levels</div>
</div></a>
<a href="search.aspx"><div class="side_menu_item">
<div class="item_title">Outstanding Complaints</div>
<div class="item_description">View status of complaints</div>
</div></a>
</div>
<div id="content_left">
<asp:ContentPlaceHolder id="Content" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</div>
<div id="footer_wrapper">
<div id="footer"><p></p></div>
</div>
</div>
</body>
</html>
Design.master.cs code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Design : System.Web.UI.MasterPage
{
public bool redirect = false;
protected override void OnInit(EventArgs e)
{
// Get the users session
SessionManager session = new SessionManager(HttpContext.Current);
// I've tried it here, and it won't redirect
// Response.Redirect("default.aspx");
redirect = true;
}
protected void Page_Load(object sender, EventArgs e)
{
// I've tried it here, and it won't redirect
// Response.Redirect("default.aspx");
}
}
Just do it in your
Page_Loadmethod fromDesign.master.cs:This is much neater than having code breaks in your markup file, and that technique will only bite you back in the future.