c# - refresh load redirection logout -
i have asp.net mvc application. have authentification form : used static class contains static boolean indicates connectivty of user:
public static class comptemodels { private static bool connected = false; public static bool connected { { return comptemodels.connected; } set { comptemodels.connected = value; } } }
in controller have snippet:
public actionresult index() { if (upload.models.comptemodels.connected) { return view(); } else return redirecttoaction("login", "account"); } public actionresult logout() { upload.models.comptemodels.connected = false; return redirecttoaction("login", "account"); }
the problem : when log in account logout if did come previous page
account page reopened (the redirection home page didn't work)
except refresh page. problem , how can coorect code?
the "problem" page cached , user seeing cached page. isn't making request site. if don't want of site cached load page server can add following attribute of controllers or base controller if have one:
[outputcache(nostore = true, duration = 0)]
you lose bandwidth saving cache if have highly sensitive data inside site might worthwhile.
i have seen other "hacks" involve making ajax request on every page load , if fails due not being authorized redirects login screen.
Comments
Post a Comment