you can use session for this. When your logged out you need to clear all session values.
if you using master page then you can write this code to master page load event.
if (Convert.ToString(Session["UserName"]).Length <= 0)
{
Response.Redirect(Page.ResolveUrl("~/default.aspx"));
}
here default page is yours login page.
and on logout you should need to write.
Session.Abandon();
Response.Redirect("../Default.aspx");