How to stay the login user to be logged in when navigating in different pageshttp://forums.asp.net/t/1801649.aspx/1?How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesThu, 10 May 2012 08:37:54 -040018016494971779http://forums.asp.net/p/1801649/4971779.aspx/1?How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesHow to stay the login user to be logged in when navigating in different pages <p>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?</p> 2012-05-09T03:20:31-04:004971807http://forums.asp.net/p/1801649/4971807.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p>hi paulalvin, you check logged in user as following</p> <pre class="prettyprint">bool val1 = System.Web.HttpContext.Current.User.Identity.IsAuthenticated or &lt;%= Page.User.Identity.IsAuthenticated %&gt;</pre> 2012-05-09T04:07:27-04:004971877http://forums.asp.net/p/1801649/4971877.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p>Im not sure but I think it it is in the web.config can somebody help? :)</p> 2012-05-09T05:06:23-04:004971887http://forums.asp.net/p/1801649/4971887.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p>Under &lt;System.Web&gt; in Web.conf</p> <p>&lt;!-- Authentication--&gt;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;authentication mode=&quot;Forms&quot;&gt;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;forms cookieless=&quot;AutoDetect&quot; defaultUrl=&quot;Default Page&quot; loginUrl=&quot;YOur Login Page&quot; enableCrossAppRedirects=&quot;false&quot; name=&quot;Your Cookie Name&quot; protection=&quot;All&quot; requireSSL=&quot;false&quot; timeout=&quot;<strong>Session Time in Minutes</strong>&quot;&nbsp; slidingExpiration=&quot;true&quot;/&gt;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;/authentication&gt;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;!-- Authorization--&gt;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;authorization&gt;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;allow users=&quot;*&quot;/&gt;</p> <p>For More Info:</p> <p>http://msdn.microsoft.com/en-us/library/ff647070.aspx</p> 2012-05-09T05:12:35-04:004972780http://forums.asp.net/p/1801649/4972780.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p></p> <blockquote><span class="icon-blockquote"></span> <h4>paulalvin</h4> <p></p> <p>Im not sure but I think it it is in the web.config can somebody help? :)</p> <p></p> </blockquote> <p></p> <p>Hello,</p> <p>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.</p> <pre class="prettyprint">&lt;location path=&quot;page.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;deny users=&quot;?&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt;</pre> 2012-05-09T12:23:36-04:004973916http://forums.asp.net/p/1801649/4973916.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p>Ok here's the scenario</p> <p>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...</p> 2012-05-10T06:39:04-04:004974040http://forums.asp.net/p/1801649/4974040.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p></p> <blockquote><span class="icon-blockquote"></span> <h4>paulalvin</h4> 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...</blockquote> <p></p> <p>Hi,</p> <p>So you need to validate whether the user is still authenticated or not, right? You can use the below code for that</p> <pre class="prettyprint">if(Request.IsAuthenticated) { //Get the user information here. }</pre> 2012-05-10T07:41:06-04:004974064http://forums.asp.net/p/1801649/4974064.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Ruchira</h4> <p></p> <pre class="prettyprint">if(Request.IsAuthenticated) { //Get the user information here. }</pre> <p></p> </blockquote> <p></p> <p></p> <p>will this work if I am using ordinary textbox(not the provided tool for login)?</p> 2012-05-10T07:51:21-04:004974097http://forums.asp.net/p/1801649/4974097.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p>Add following in &lt;System.Web&gt; section in Web.Conf. Put your login page url and default page url where mentioned.&nbsp;&nbsp; &nbsp;</p> <pre class="prettyprint">&lt;authentication mode=&quot;Forms&quot;&gt; &lt;forms cookieless=&quot;AutoDetect&quot; defaultUrl=&quot;Default Page&quot; loginUrl=&quot;Your Login PageUrl&quot; r timeout=&quot;Session Time in Minutes&quot; slidingExpiration=&quot;true&quot;/&gt; &lt;/authentication&gt; &lt;authorization&gt; &lt;allow users=&quot;*&quot;/&gt; &lt;/authorization&gt;</pre> <p>Now in masterpage load event or in those pages where user authentication is needed do it in Page_Load Event:</p> <pre class="prettyprint"><span class="kwd">if</span><span class="pun">(!</span><span class="typ">Request</span><span class="pun">.</span><span class="typ">IsAuthenticated</span><span class="pun">)</span><span class="pln">//if user is not authenticated<br /></span><span class="pun">{</span><span class="pln"><br />&nbsp; </span><span class="pln">&nbsp;FormsAuthentication.RedirectToLoginPage();//not allow to access and redirect to login<br /></span><span class="pun">}</span></pre> <pre class="prettyprint"> It will work even if you are not using login control. I am successfully using it my project.</pre> <pre class="prettyprint"><span class="pun"><br /></span></pre> 2012-05-10T08:07:13-04:004974161http://forums.asp.net/p/1801649/4974161.aspx/1?Re+How+to+stay+the+login+user+to+be+logged+in+when+navigating+in+different+pagesRe: How to stay the login user to be logged in when navigating in different pages <p></p> <blockquote><span class="icon-blockquote"></span> <h4>paulalvin</h4> will this work if I am using ordinary textbox(not the provided tool for login)?</blockquote> <p></p> <p>No.</p> 2012-05-10T08:37:54-04:00