User authentication on page load
I have an application and the user must be logged in before they can access the pages. now, as soon as the user logs in, I store the user's data in a session variable (eg Session ["CurrentUser"]).
now if the user tries to go to the page directly, i check if the Session ["CurrentUser"] value is or not ... if not then the user will be redirected to the login page ...
My problem is that I have done this, or rather have written this "validation code" in almost all of the pages.
I want this code to stay in a specific place and I will just refer to this method all the time in all pages ... now where should I write this method?
thanks.
a source to share
You should take a look at ASP.NET Authentication . This will allow you to secure a section of your website or individual pages through the web.config file and use a cookie for authentication instead of checking the session variable.
a source to share