ASP.NET

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP.NET

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 30th, 2012, 11:53 AM
imbryan80 imbryan80 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 1 imbryan80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m
Reputation Power: 0
Login control with sessions

Hello every one,

I am new in asp.net development.
I am doing project in asp.net with vb.
I am using inbuilt login control and created sessions. Some times sessions works but sometimes gives errors. specially when I log out and login back in system. Also not able to clear sessions whil logging out the system.

Please help me.

Reply With Quote
  #2  
Old February 21st, 2013, 05:35 AM
VanessaMeacham VanessaMeacham is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Location: USA
Posts: 53 VanessaMeacham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 59 m 31 sec
Reputation Power: 2
Session Issue

HI ! i give you one example with coding i hope it will help you.


public class BasePage : System.Web.UI.Page
{
public SecurityApplicationPageBase()
{
this.Load += new System.EventHandler(this.Page_Load);
}

private void Page_Load(object sender, System.EventArgs e)
{

if(Session["Session_name"]==null)
{
Response.Redirect("Login.aspx");
}
InjectSessionExpireScript();
}

// For demo purpose the timeout is set to a smaller value.
//Remember The Javascript setTimeout works in milliseconds.
protected void InjectSessionExpireScript( )
{
string script = "<script> \n" +
"function expireSession(){ \n"+
" window.location = '"+"Logout.aspx"+"'}\n"+
"setTimeout('expireSession()', " +this.Session.Timeout * 1000 +" ); \n"+
"</script>"
this.Page.RegisterClientScriptBlock("expirescript",script);
}
}

Logout Page: This page calls Session.Abandon() and redirects to the login.aspx page.

public class LogOut : BasePage
{
private void Page_Load(object sender, System.EventArgs e)
{
Session.Abandon();
Response.Redirect("Login.aspx",true);
}
}

Login Page: This page facilitates login. On a successful login a Session variable is created.


public class LogIn : System.Web.UI.Page
{

private void btnLogin_Click(object sender, System.EventArgs e)
{
//when username and pasword is correct
Session.Add("Session_name","loggedinsuccessfully");
}
}

Reply With Quote
  #3  
Old April 30th, 2013, 08:03 AM
annaharris annaharris is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2013
Posts: 27 annaharris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 28 sec
Reputation Power: 0
You may face some issues while using the inbuilt login control by Asp.net. Try your own custom built login control.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP.NET > Login control with sessions


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap