After Logout prevent back navigation in ASP.Net MVC

on May 27, 2013 01:48 AM

I have a problem when user logout and hit the back button of the browser the pages are showing from browser history

my need is after logout if user clicks on back button it doesnot go previcious pages how to do this MVC my code pasted here


 public ActionResult LogOut() 
            UserInformation user = null;
            if (Session["LoginUser"] != null)
                user = (UserInformation)Session["LoginUser"];
                user.IsLoggedIn = false; 
                Services1 s1 = new Services1();
                string result = s1.UpdateLoginStatus(user); 
            //Deleting user directory in server
            string tempDir = "C:\\InndocsiHealth\\PDFFiles\\" + user.UserId;
            string[] files = null;
            if (Directory.Exists(tempDir))
                files = Directory.GetFiles(tempDir);
                foreach (string file in files)
                    if (System.IO.File.Exists(file))

                Directory.Delete(tempDir, true);

            return RedirectToActionPermanent("Home", "Home", new { area = "" });


Download FREE API for Word, Excel and PDF in ASP.Net: Download
on May 27, 2013 01:48 AM

You need to check Session on all pages and if Session is NULL redirect to Login page