If I want to use my own database how can I ensure that the logged in user will still be logged in when he navigates through the different pages of asp.net?
Im not sure but I think it it is in the web.config can somebody help? :)
Hello,
I'm not sure what you are looking for. But you can add the following in the web.config for each page so it will deny access if the user is not authorized.
On the first page the user need to login and after the successfull login he can navigate through the different pages in the website. For example there's a transaction on one page I want the userid or other information about the currently login user to be
the one stored in my database...
On the first page the user need to login and after the successfull login he can navigate through the different pages in the website. For example there's a transaction on one page I want the userid or other information about the currently login user to be the
one stored in my database...
Hi,
So you need to validate whether the user is still authenticated or not, right? You can use the below code for that
if(Request.IsAuthenticated)
{
//Get the user information here.
}
paulalvin
Member
229 Points
246 Posts
How to stay the login user to be logged in when navigating in different pages
May 09, 2012 03:20 AM|LINK
If I want to use my own database how can I ensure that the logged in user will still be logged in when he navigates through the different pages of asp.net?
santosh.jagd...
Star
7625 Points
1454 Posts
Re: How to stay the login user to be logged in when navigating in different pages
May 09, 2012 04:07 AM|LINK
hi paulalvin, you check logged in user as following
MCP
paulalvin
Member
229 Points
246 Posts
Re: How to stay the login user to be logged in when navigating in different pages
May 09, 2012 05:06 AM|LINK
Im not sure but I think it it is in the web.config can somebody help? :)
mishra.bhupe...
Participant
1594 Points
376 Posts
Re: How to stay the login user to be logged in when navigating in different pages
May 09, 2012 05:12 AM|LINK
Under <System.Web> in Web.conf
<!-- Authentication-->
<authentication mode="Forms">
<forms cookieless="AutoDetect" defaultUrl="Default Page" loginUrl="YOur Login Page" enableCrossAppRedirects="false" name="Your Cookie Name" protection="All" requireSSL="false" timeout="Session Time in Minutes" slidingExpiration="true"/>
</authentication>
<!-- Authorization-->
<authorization>
<allow users="*"/>
For More Info:
http://msdn.microsoft.com/en-us/library/ff647070.aspx
Ruchira
All-Star
42936 Points
7023 Posts
MVP
Re: How to stay the login user to be logged in when navigating in different pages
May 09, 2012 12:23 PM|LINK
Hello,
I'm not sure what you are looking for. But you can add the following in the web.config for each page so it will deny access if the user is not authorized.
<location path="page.aspx"> <system.web> <authorization> <deny users="?"/> </authorization> </system.web> </location>
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.paulalvin
Member
229 Points
246 Posts
Re: How to stay the login user to be logged in when navigating in different pages
May 10, 2012 06:39 AM|LINK
Ok here's the scenario
On the first page the user need to login and after the successfull login he can navigate through the different pages in the website. For example there's a transaction on one page I want the userid or other information about the currently login user to be the one stored in my database...
Ruchira
All-Star
42936 Points
7023 Posts
MVP
Re: How to stay the login user to be logged in when navigating in different pages
May 10, 2012 07:41 AM|LINK
Hi,
So you need to validate whether the user is still authenticated or not, right? You can use the below code for that
if(Request.IsAuthenticated) { //Get the user information here. }
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.paulalvin
Member
229 Points
246 Posts
Re: How to stay the login user to be logged in when navigating in different pages
May 10, 2012 07:51 AM|LINK
will this work if I am using ordinary textbox(not the provided tool for login)?
mishra.bhupe...
Participant
1594 Points
376 Posts
Re: How to stay the login user to be logged in when navigating in different pages
May 10, 2012 08:07 AM|LINK
Add following in <System.Web> section in Web.Conf. Put your login page url and default page url where mentioned.
<authentication mode="Forms"> <forms cookieless="AutoDetect" defaultUrl="Default Page" loginUrl="Your Login PageUrl" r timeout="Session Time in Minutes" slidingExpiration="true"/> </authentication> <authorization> <allow users="*"/> </authorization>Now in masterpage load event or in those pages where user authentication is needed do it in Page_Load Event:
Ruchira
All-Star
42936 Points
7023 Posts
MVP
Re: How to stay the login user to be logged in when navigating in different pages
May 10, 2012 08:37 AM|LINK
No.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.