public override void OnActionExecuting(ActionExecutingContext filterContext) { string url = filterContext.HttpContext.Request.Headers["Referer"].ToString(); AppFunctions functions = new AppFunctions(); string newUrl = functions.Url(filterContext.HttpContext.Request); if (newUrl.Contains("CheckExistingPassword") && !url.Contains("CheckExistingPassword")) { newUrl = url; } if (!_sessionManager.IsLoggedIn) { _sessionManager.LastAccessedUrl = newUrl; filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { { "Controller", "SignIn" }, { "Action", "Index" } }); } }