473,624 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hyperlinking and ASP.NEt Session

Hi,

I am trying to design a Home page for my applicatiion in which i want show
the links for for some itms...
I tried to put the following
<td>
<font face="Arial, Helvetica, sans-serif" color="#ffffff" size="2"> Contact
| My Profile | Logout /font>
</td>

Here i want to have link for the above options to respective pages, i tried
with anchor <A></A> with HREF attribute, but i don't want to see the
underline for the link., i am not sure of how to do that...would anyone help
me in this regard.

ASP.NET Session variables Questions?

1) How to discard session variables? Are all session variables cleared when
the code FormsAuthentica tion.SignOut() is executed for Forms authentication
web
applications (i am sessing this not happening, even after using
Session.Abandon (), Session.Clear() )

2) Is session variables persistent across hyperliks (i think it is not,
since each hyperlink will assume diferent session)

3) How to check for user Session expiration to pop up a messgae saying
"Session Expired, goto Login page"

Thanks
Nedu

Nov 18 '05 #1
6 2559
See inline comments.
I am trying to design a Home page for my applicatiion in which i want show
the links for for some itms...
I tried to put the following
<td>
<font face="Arial, Helvetica, sans-serif" color="#ffffff" size="2"> Contact | My Profile | Logout /font>
</td>

Here i want to have link for the above options to respective pages, i tried with anchor <A></A> with HREF attribute, but i don't want to see the
underline for the link., i am not sure of how to do that...would anyone help me in this regard.
Use stylesheets for your links.

<style>
a.navlink
{
font-family: arial, helvetica, sans-serif;
font-size: 11px;
color: #ffffff;
text-decoration: none;
}
</style>

<a href="blah.aspx " class="navlink" >Contact</a> ...etc

ASP.NET Session variables Questions?

1) How to discard session variables? Are all session variables cleared when the code FormsAuthentica tion.SignOut() is executed for Forms authentication web applications (i am sessing this not happening, even after using
Session.Abandon (), Session.Clear() )
FormsAuthentica tion.SignOut() will clear the session variables set by the
ASP.NET authentication system. However, if you hit back on your browser,
the page will be pulled from your browser cache, and will display. Hitting
refresh on this page will cause it to re-request the page from the server,
at which point it will realise you are no longer logged in, and will
redirect to the login page, as defined in web.config.

2) Is session variables persistent across hyperliks (i think it is not,
since each hyperlink will assume diferent session)
Session variables are persistent across a users session, across hyperlinks
within the same domain and IIS application.

3) How to check for user Session expiration to pop up a messgae saying
"Session Expired, goto Login page"


You will need to do this using Javascript and timers. Create a timer on
each page load, in which you pass in the session timeout. When the timer
elapses, use the alert command to display a warning message.
Regards,

Mun

Nov 18 '05 #2
Thanks Mun.
I was trying to use Timer object for Session Timeout popup and redirect
already, but it was not not working...
would you give me exaple of how to code time controls to popup a message and
redirect to login page when the session times out..
(using Session.Timeout property to determine the session timout).

Thanks
Nedu

"Munsifali Rashid" <mun.news@#Remo veToReply#cordl essmouse.co.uk> wrote in
message news:eB******** ******@TK2MSFTN GP12.phx.gbl...
See inline comments.
I am trying to design a Home page for my applicatiion in which i want show the links for for some itms...
I tried to put the following
<td>
<font face="Arial, Helvetica, sans-serif" color="#ffffff" size="2"> Contact
| My Profile | Logout /font>
</td>

Here i want to have link for the above options to respective pages, i

tried
with anchor <A></A> with HREF attribute, but i don't want to see the
underline for the link., i am not sure of how to do that...would anyone

help
me in this regard.


Use stylesheets for your links.

<style>
a.navlink
{
font-family: arial, helvetica, sans-serif;
font-size: 11px;
color: #ffffff;
text-decoration: none;
}
</style>

<a href="blah.aspx " class="navlink" >Contact</a> ...etc

ASP.NET Session variables Questions?

1) How to discard session variables? Are all session variables cleared

when
the code FormsAuthentica tion.SignOut() is executed for Forms

authentication
web applications (i am sessing this not happening, even after using
Session.Abandon (), Session.Clear() )


FormsAuthentica tion.SignOut() will clear the session variables set by the
ASP.NET authentication system. However, if you hit back on your browser,
the page will be pulled from your browser cache, and will display.

Hitting refresh on this page will cause it to re-request the page from the server,
at which point it will realise you are no longer logged in, and will
redirect to the login page, as defined in web.config.

2) Is session variables persistent across hyperliks (i think it is not,
since each hyperlink will assume diferent session)


Session variables are persistent across a users session, across hyperlinks
within the same domain and IIS application.

3) How to check for user Session expiration to pop up a messgae saying
"Session Expired, goto Login page"


You will need to do this using Javascript and timers. Create a timer on
each page load, in which you pass in the session timeout. When the timer
elapses, use the alert command to display a warning message.
Regards,

Mun

Nov 18 '05 #3
Hi Nedu,

Instead of a timer object, you may use the setTimeout method, for example:

window.setTimeo ut(window.alert (""Session Expired, goto Login page!",100000)

For more information on this method, you can refer to:

http://msdn.microsoft.com/library/de...thor/dhtml/ref
erence/methods/setTimeout.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
What you need to do, is start a javascript timer on each page load, and then
update the timer every second until the session expires. If the user
navigates to a different page, the clock will reset as they are actively
using the session.

Create a timers javascript file and put the following two functions in it.
This script must be referenced in every page on which you want to show the
popup. I.e. save it as "includes/timers.js" and then each page must
reference it using <script language="JavaS cript"
src="includes/timers.js"></script>.
function startClock()
{
dWatch = 0;
dStarted = new Date();
}
function updateClock(iTi meOutAlert)
{
setTimeout("upd ateClock('" + iTimeOutAlert + "');", 100);
dNow = new Date();
dWatch = dNow.getTime() - dStarted.getTim e();
dClock = Math.round(dWat ch/1000);
if (dClock == iTimeOutAlert)
{
alert("Warning! \n\nYour session has expired.\nRedir ecting to login
page...");
window.location .href = "loginpage.aspx ";
}
}
Once this is done, you need to modify pages using the alert to call
startClock() and updateClock(). You can do this using the following (in the
Page_Load function):
[C#]
int intTimeOut = Session.Timeout *100;
string strTimerScript = "startClock();u pdateClock(" + intTimeOut.ToSt ring()
+ ");"
Page.RegisterSt artupScript("ti merScript", strTimerScript) ;
[VB.NET]
Dim intTimeOut as Integer = Session.Timeout *100
Dim strTimerScript As String = "startClock();u pdateClock(" &
intTimeOut.ToSt ring() & ");"
Page.RegisterSt artupScript("ti merScript", strTimerScript)
This code sample is constructed partly from memory, and partly from some
code snippets I had floating around. Haven't used it for a coupla years
now, though it worked perfectly back then, but it was being used on a
classic ASP website, not .NET. That shouldn't be an issue though, as it's
all client-side code. If there's any problems, let me know, and I'll try
and help :-)

Regards,

Mun

"Nedu N" <ne****@hotmail .com> wrote in message
news:un******** ******@TK2MSFTN GP11.phx.gbl...
Thanks Mun.
I was trying to use Timer object for Session Timeout popup and redirect
already, but it was not not working...
would you give me exaple of how to code time controls to popup a message and redirect to login page when the session times out..
(using Session.Timeout property to determine the session timout).

Thanks
Nedu

Nov 18 '05 #5
Thanks Mun...
I tried but i am make it working...i just tried with the script that you
gave me..

I created a js file in my project itself - TimeoutTimer.js
and i referenced this on one of my page's HTML as reference it using <script
language="JavaS cript"
src="TimeoutTim er.js"></script>.

and i had following code in my page load
Session.Timeout = 10; //i am ust overriding this...

int intTimeOut = Session.Timeout * 100;

Global.strScrip t = "startClock();u pdateClock(" + intTimeOut.ToSt ring() + ");

Page.RegisterSt artupScript("ti merScript", Global.strScrip t);

But the output that i am getting is the following displayed on my page as a
string...i think the the javascript was not executed...woud l u please tell
me what is the problem since i am new to scripts..

startClock();up dateClock(1000)

"Munsifali Rashid" <mun@**RemoveTo Reply**vefuk.co m> wrote in message
news:OC******** ******@tk2msftn gp13.phx.gbl...
What you need to do, is start a javascript timer on each page load, and then update the timer every second until the session expires. If the user
navigates to a different page, the clock will reset as they are actively
using the session.

Create a timers javascript file and put the following two functions in it.
This script must be referenced in every page on which you want to show the
popup. I.e. save it as "includes/timers.js" and then each page must
reference it using <script language="JavaS cript"
src="includes/timers.js"></script>.
function startClock()
{
dWatch = 0;
dStarted = new Date();
}
function updateClock(iTi meOutAlert)
{
setTimeout("upd ateClock('" + iTimeOutAlert + "');", 100);
dNow = new Date();
dWatch = dNow.getTime() - dStarted.getTim e();
dClock = Math.round(dWat ch/1000);
if (dClock == iTimeOutAlert)
{
alert("Warning! \n\nYour session has expired.\nRedir ecting to login
page...");
window.location .href = "loginpage.aspx ";
}
}
Once this is done, you need to modify pages using the alert to call
startClock() and updateClock(). You can do this using the following (in the Page_Load function):
[C#]
int intTimeOut = Session.Timeout *100;
string strTimerScript = "startClock();u pdateClock(" + intTimeOut.ToSt ring() + ");"
Page.RegisterSt artupScript("ti merScript", strTimerScript) ;
[VB.NET]
Dim intTimeOut as Integer = Session.Timeout *100
Dim strTimerScript As String = "startClock();u pdateClock(" &
intTimeOut.ToSt ring() & ");"
Page.RegisterSt artupScript("ti merScript", strTimerScript)
This code sample is constructed partly from memory, and partly from some
code snippets I had floating around. Haven't used it for a coupla years
now, though it worked perfectly back then, but it was being used on a
classic ASP website, not .NET. That shouldn't be an issue though, as it's
all client-side code. If there's any problems, let me know, and I'll try
and help :-)

Regards,

Mun

"Nedu N" <ne****@hotmail .com> wrote in message
news:un******** ******@TK2MSFTN GP11.phx.gbl...
Thanks Mun.
I was trying to use Timer object for Session Timeout popup and redirect
already, but it was not not working...
would you give me exaple of how to code time controls to popup a message

and
redirect to login page when the session times out..
(using Session.Timeout property to determine the session timout).

Thanks
Nedu


Nov 18 '05 #6
There's an error in the code - I forgot to wrap the javascript in <script>
tags.

Global.strScrip t = "startClock();u pdateClock(" + intTimeOut.ToSt ring() + ");

Should be:

Global.strScrip t = "<script language='JavaS cript'>startClo ck();updateCloc k("
+ intTimeOut.ToSt ring() + ");</script>";

Also, the number passed in should be the Session.Timeout in seconds, so
intTimeOut should be:

int intTimeOut = Session.Timeout * 60;

I've just tested this code, and it seems to be working.

Hope this helps,

Mun

"Nedu N" <ne****@hotmail .com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Thanks Mun...
I tried but i am make it working...i just tried with the script that you
gave me..

I created a js file in my project itself - TimeoutTimer.js
and i referenced this on one of my page's HTML as reference it using <script language="JavaS cript"
src="TimeoutTim er.js"></script>.

and i had following code in my page load
Session.Timeout = 10; //i am ust overriding this...

int intTimeOut = Session.Timeout * 100;

Global.strScrip t = "startClock();u pdateClock(" + intTimeOut.ToSt ring() + ");
Page.RegisterSt artupScript("ti merScript", Global.strScrip t);

But the output that i am getting is the following displayed on my page as a string...i think the the javascript was not executed...woud l u please tell
me what is the problem since i am new to scripts..

startClock();up dateClock(1000)


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7779
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
27
7109
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the user accesses it (not just once and then store it in the session). If a secure app is multi-page,...
2
3304
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals and a couple "better pratice" code. Not perfect, but better. Problem : I'm testing everything with Firefox on my machine (IIS on WinXP Pro), and everything is ok. As soon as I try MS IE 6, it doesn't seem to keep the sessions from page to...
13
23300
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 The problem I am having is that each time I reload the same PHP page, I get
0
3230
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te documentation it seems it should do it anyway any advice?
14
2364
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and User B has access to 5, now when both of us hits to the server at the same time then their session variables gets mixedup means either User A and USer B will have now 5 companies or both have 10 companies. Now again when User A hits to the server...
7
3963
by: aroraamit81 | last post by:
Well Guys, Here is a very strange trouble. When more than one users request tto same page at the same time then our session gets conflicted. Moreover I printed my SessionID, strangely but true I got the exact same SessionID as of other users's. Well I guess nothing wrong with my code, do I need to set any property in Web.Config file??
1
2584
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking name of that file from attaching file page to email page through in session file .i am giving a facility of attaching five files to user . and i am taking names of both files in session variables but user attach less than five five
5
2428
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.