Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Thursday, March 29, 2012

session value lost

Hello NG,

I have three files (default.aspx, search.aspx and work.aspx). The way
is: login on default (if session is newsession). The loginname I write
into as sessionvariable (username). So I redirect to my search.aspx.
Here I have a form which allows fill in some fields (place, street,
name etc.). With this informations i build a sqlquerey for sqlserver,
fill a datagrid and after select the right record by usin a link behind
I save the recordid to the session and redirect to work.aspx. With a
new sqlstring I fetch the data from the sqlserver. But this data is
only to display. The user can edit Data for a new record in anoter
table and end it wiht button click. Here I will save all sessionvalues
(username, and recordinformation) with sqlstring and redirect to
search.aspx.

Now the problems:
1. I don't no what I've changed - but I have to...
After redirection from work to search I've got an sql-error. The string
will be cleard before building new, so why does it run once, but not
after redirect?
2. I solved this problem with redirecting from work to default. Its
running. But: the session username is empty - why?
3. I solved with writing the username in an hidden field on
default.aspx, read it again and write to session. Everything is fine.
4. Now we can work, and I will change the username from manuel login to
reading from client windows. But I realy want to know why I have the
Problems 1 to 3 and problem no 4 is: some stored records have no
username within. Who can explain it to me - who as a solution to solve
the problems?You might want to share the source code for your search.aspx page so
we can look it over.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 27 Jun 2005 07:46:30 -0700, "catweezle2010" <catweezle2010@.gmx.de>
wrote:

>Hello NG,
>I have three files (default.aspx, search.aspx and work.aspx). The way
>is: login on default (if session is newsession). The loginname I write
>into as sessionvariable (username). So I redirect to my search.aspx.
>Here I have a form which allows fill in some fields (place, street,
>name etc.). With this informations i build a sqlquerey for sqlserver,
>fill a datagrid and after select the right record by usin a link behind
>I save the recordid to the session and redirect to work.aspx. With a
>new sqlstring I fetch the data from the sqlserver. But this data is
>only to display. The user can edit Data for a new record in anoter
>table and end it wiht button click. Here I will save all sessionvalues
>(username, and recordinformation) with sqlstring and redirect to
>search.aspx.
>Now the problems:
>1. I don't no what I've changed - but I have to...
>After redirection from work to search I've got an sql-error. The string
>will be cleard before building new, so why does it run once, but not
>after redirect?
>2. I solved this problem with redirecting from work to default. Its
>running. But: the session username is empty - why?
>3. I solved with writing the username in an hidden field on
>default.aspx, read it again and write to session. Everything is fine.
>4. Now we can work, and I will change the username from manuel login to
>reading from client windows. But I realy want to know why I have the
>Problems 1 to 3 and problem no 4 is: some stored records have no
>username within. Who can explain it to me - who as a solution to solve
>the problems?
Hi Allen,

it will be to much code but I think, it's better for understanding:

I start with the default.aspx. If the session is new, nothing will
happen unless the user logs in - no problem. When I come from my last
page (call.aspx) the sessionvariable 'user' has still a value. When I
redirect to my second page (suche.aspx) this value will be lost. So I
do this workaround:

default.aspx

Sub Page_Load (ByVal Sender As Object, _
ByVal E As EventArgs)

Session("KD_VNAME")=""
Session("KD_NAME")=""
Session("STADT")=""
Session("PLZ")=""
Session("STRASSE")=""

If Session.IsNewSession Then
TextBox1.value="neu"
else
if ispostback then
Session("Anwendername") = TextBoxLogin.value
TextBox1.value=Session("Anwendername")
response.redirect("suche.aspx")
else
TextBox1.value=Session("Anwendername")
Session("Anwendername") = TextBox1.value
response.redirect("suche.aspx")
end if
end if

When loading the suche.aspx I check on newsession and if not I will
clear the value of some session varialbes:

suche.aspx

Sub Page_Load (ByVal Sender As Object, _
ByVal E As EventArgs)

If Session.IsNewSession Then
response.redirect("default.aspx")
else
dataSet
end if
end sub

public sub DataSet()
Session("KD_VNAME")=""
Session("KD_NAME")=""
Session("STADT")=""
Session("PLZ")=""
Session("STRASSE")=""
Datagrid1.DataBind()
end sub

After the user filled in the search date the function will be called.
First I had a redirect form my last page (call.aspx) back to this one.
If I am first on the page everything is fine. The second time, after
redirect I get an error, which means the sql statement is incorrect.
But there can no old value - I clear it. So I redirect to the
default.aspx:

function DatenSuche() As System.Data.IDataReader
Dim connectionString As String = "Data Source=mssql;Initial
Catalog=DB;User Id=huser;Password=passw;Connect Timeout=15;Network
Library=dbmssocn;"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)
Dim queryString As String = ""
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand

if TextBox_Name.text <> "" then
if queryString <> "" then
queryString = querystring & " and "
end if
queryString = queryString & "[KD_NAME] like N'" & TextBox_Name.text
& "%' "
end if
if TextBox_Vorname.text <> "" then
if queryString <> "" then
queryString = querystring & " and "
end if
queryString = queryString & "[KD_VNAME] like N'" &
TextBox_Vorname.text & "%' "
end if

queryString = "SELECT [View_Such].* FROM [View_Such] WHERE (" &
queryString & ")"
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
dataReader.close
dbConnection.close
connectionString = ""
queryString = ""
end function

call.aspx

public sub ButtonEnde_Click(sender As Object, e As EventArgs)
response.redirect("default.aspx")
'response.redirect("suche.aspx")
end sub

Any idea?
One thing you may want to try is to use:

Response.Redirect("page", False);

Whenever you are in a page where the user might have started a
session. See:
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx

Another approach I'd try is to not use so many redirects, but drop a
panel control on your form and keep the search results inside the
panel. You can set the Visible property of the panel to false, and
toggle the value to true when there are search results to display.
This might make the page easier to work with.

--
Scott
http://www.OdeToCode.com/blogs/scott/]

On 29 Jun 2005 04:04:53 -0700, "catweezle2010" <catweezle2010@.gmx.de>
wrote:

>Hi Allen,
>it will be to much code but I think, it's better for understanding:
>I start with the default.aspx. If the session is new, nothing will
>happen unless the user logs in - no problem. When I come from my last
>page (call.aspx) the sessionvariable 'user' has still a value. When I
>redirect to my second page (suche.aspx) this value will be lost. So I
>do this workaround:
>default.aspx
>Sub Page_Load (ByVal Sender As Object, _
> ByVal E As EventArgs)
> Session("KD_VNAME")=""
> Session("KD_NAME")=""
> Session("STADT")=""
> Session("PLZ")=""
> Session("STRASSE")=""
>If Session.IsNewSession Then
> TextBox1.value="neu"
> else
> if ispostback then
> Session("Anwendername") = TextBoxLogin.value
> TextBox1.value=Session("Anwendername")
> response.redirect("suche.aspx")
> else
> TextBox1.value=Session("Anwendername")
> Session("Anwendername") = TextBox1.value
> response.redirect("suche.aspx")
> end if
> end if
>When loading the suche.aspx I check on newsession and if not I will
>clear the value of some session varialbes:
>suche.aspx
>Sub Page_Load (ByVal Sender As Object, _
> ByVal E As EventArgs)
>If Session.IsNewSession Then
> response.redirect("default.aspx")
> else
> dataSet
> end if
>end sub
>public sub DataSet()
>Session("KD_VNAME")=""
> Session("KD_NAME")=""
> Session("STADT")=""
> Session("PLZ")=""
> Session("STRASSE")=""
> Datagrid1.DataBind()
>end sub
>
>After the user filled in the search date the function will be called.
>First I had a redirect form my last page (call.aspx) back to this one.
>If I am first on the page everything is fine. The second time, after
>redirect I get an error, which means the sql statement is incorrect.
>But there can no old value - I clear it. So I redirect to the
>default.aspx:
>function DatenSuche() As System.Data.IDataReader
> Dim connectionString As String = "Data Source=mssql;Initial
>Catalog=DB;User Id=huser;Password=passw;Connect Timeout=15;Network
>Library=dbmssocn;"
> Dim dbConnection As System.Data.IDbConnection = New
>System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = ""
> Dim dbCommand As System.Data.IDbCommand = New
>System.Data.SqlClient.SqlCommand
> if TextBox_Name.text <> "" then
>if queryString <> "" then
> queryString = querystring & " and "
> end if
> queryString = queryString & "[KD_NAME] like N'" & TextBox_Name.text
>& "%' "
> end if
> if TextBox_Vorname.text <> "" then
> if queryString <> "" then
> queryString = querystring & " and "
> end if
> queryString = queryString & "[KD_VNAME] like N'" &
>TextBox_Vorname.text & "%' "
> end if
>
> queryString = "SELECT [View_Such].* FROM [View_Such] WHERE (" &
>queryString & ")"
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
>dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> dataReader.close
> dbConnection.close
> connectionString = ""
> queryString = ""
>end function
>
>call.aspx
>public sub ButtonEnde_Click(sender As Object, e As EventArgs)
> response.redirect("default.aspx")
> 'response.redirect("suche.aspx")
> end sub
>
>
>Any idea?

session variable

Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

Below is web.config snippet...

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/
Anyone has any clue why its happening like this??

Any help would be appreciated..

Thanx in advance

daveA couple comments. First off, you might save yourself a handful of lines of code as well as this problem if you used the built-in FormsAuthentication:
http://www.15seconds.com/issue/020220.htm
http://www.15seconds.com/issue/020305.htm

I suspect they are getting to index.aspx because the page is cached...hence when they force a refresh they are being logged out. You might want to look at :
http://www.15seconds.com/issue/010202.htm
which will tell you how to make sure the browser doesn't cache the page.

As for why ur session doesn't clear, you might wanna try Response.Redirect("default.aspx", false) If that works check out :
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx for why...not sure if that applies to clearing session though, don't think so.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!)

"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

Below is web.config snippet...

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/
Anyone has any clue why its happening like this??

Any help would be appreciated..

Thanx in advance

dave
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

In C# I would not check for an empty string, but for null. In VB you might need to
check for "Nothing".
You don't store "strings" in Session, you store "objects". A string is a perfectly
valid object, so you can store it without problems. But if the Session variable
has been removed, it's *removed* (not there, nothing), not an empty string.
But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

If you use Redirect, you instruct the browser to go to a different URL, so that other
URL should be displayed (If you had used Transfer, this would not be the case, as that
works entirely server-side). So you are not "redirected" to default.aspx, but something else
happened.

Hans Kesting

session variable

Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
Below is web.config snippet...
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Anyone has any clue why its happening like this'
Any help would be appreciated..
Thanx in advance
daveA couple comments. First off, you might save yourself a handful of lines of
code as well as this problem if you used the built-in FormsAuthentication:
http://www.15seconds.com/issue/020220.htm
http://www.15seconds.com/issue/020305.htm
I suspect they are getting to index.aspx because the page is cached...hence
when they force a refresh they are being logged out. You might want to look
at :
http://www.15seconds.com/issue/010202.htm
which will tell you how to make sure the browser doesn't cache the page.
As for why ur session doesn't clear, you might wanna try Response.Redirect("
default.aspx", false) If that works check out :
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx for why...not
sure if that applies to clearing session though, don't think so.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!
)
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP
14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
Below is web.config snippet...
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Anyone has any clue why its happening like this'
Any help would be appreciated..
Thanx in advance
dave
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP
14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
In C# I would not check for an empty string, but for null. In VB you might n
eed to
check for "Nothing".
You don't store "strings" in Session, you store "objects". A string is a per
fectly
valid object, so you can store it without problems. But if the Session varia
ble
has been removed, it's *removed* (not there, nothing), not an empty string.
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
If you use Redirect, you instruct the browser to go to a different URL, so t
hat other
URL should be displayed (If you had used Transfer, this would not be the cas
e, as that
works entirely server-side). So you are not "redirected" to default.aspx, bu
t something else
happened.
Hans Kesting

Session variable being cleared--why?

When I visit a specific web page, Request.aspx, for some reason my session
variables are cleared.
I noticed that there is a "EnableSessionState" property on the document
object that has three allowed states "True", "false" and "Readonly". I
would assume that by default, if not specified, it is "true".
however, I decided to explicitly set it to true to see if it helps.
i set it to true in the WebForm. no luck.. Then i realized that it used a
Master Page, so I tried to set the same property there to true.
I get the following error message:
Error 3 Error parsing attribute 'enablesessionstate': Type
'System.Web.UI.MasterPage' does not have a public property named
'enablesessionstate'.
C:\MyDocs\vss\SMIT\SMIT.PackTrack\PackTrack.NET\BIMasterPage.master 1
Any idea why I can't set this property or how to prevent the Session
Variable from being cleared. I access the web page using a relative Url, do
not explicitly clear the variable, am not using frames, am using only 1 IE
Window.
Can anyone suggest a reason why this is happending?
Also, on a separate thought...Is there any easy way to log response times
(Page Post times) in a centralized way such as the ASAX file. I assume there
is something in TRACING, but I dont know much about. A little direction
point would be helpful.
Thanks!I found the issue:
I did something like this is the top of my aspx code behind class:
Private UserId As String = Session("UserId")
I change it to
Private UserId As String
and in the form load add:
UserId = Session("UserId")
Apparently, variables are initialized before the session object is
avaialable for use.
"Chad" <chad.dokmanovich@.unisys.com> wrote in message
news:f46kr0$isr$1@.trsvr.tr.unisys.com...
> When I visit a specific web page, Request.aspx, for some reason my session
> variables are cleared.
> I noticed that there is a "EnableSessionState" property on the document
> object that has three allowed states "True", "false" and "Readonly". I
> would assume that by default, if not specified, it is "true".
> however, I decided to explicitly set it to true to see if it helps.
> i set it to true in the WebForm. no luck.. Then i realized that it used a
> Master Page, so I tried to set the same property there to true.
> I get the following error message:
> Error 3 Error parsing attribute 'enablesessionstate': Type
> 'System.Web.UI.MasterPage' does not have a public property named
> 'enablesessionstate'.
> C:\MyDocs\vss\SMIT\SMIT.PackTrack\PackTrack.NET\BIMasterPage.master 1
>
> Any idea why I can't set this property or how to prevent the Session
> Variable from being cleared. I access the web page using a relative Url,
> do not explicitly clear the variable, am not using frames, am using only 1
> IE Window.
> Can anyone suggest a reason why this is happending?
> Also, on a separate thought...Is there any easy way to log response times
> (Page Post times) in a centralized way such as the ASAX file. I assume
> there is something in TRACING, but I dont know much about. A little
> direction point would be helpful.
> Thanks!
>
>

Session variable being cleared--why?

When I visit a specific web page, Request.aspx, for some reason my session
variables are cleared.

I noticed that there is a "EnableSessionState" property on the document
object that has three allowed states "True", "false" and "Readonly". I
would assume that by default, if not specified, it is "true".

however, I decided to explicitly set it to true to see if it helps.

i set it to true in the WebForm. no luck.. Then i realized that it used a
Master Page, so I tried to set the same property there to true.

I get the following error message:

Error 3 Error parsing attribute 'enablesessionstate': Type
'System.Web.UI.MasterPage' does not have a public property named
'enablesessionstate'.
C:\MyDocs\vss\SMIT\SMIT.PackTrack\PackTrack.NET\BI MasterPage.master 1

Any idea why I can't set this property or how to prevent the Session
Variable from being cleared. I access the web page using a relative Url, do
not explicitly clear the variable, am not using frames, am using only 1 IE
Window.

Can anyone suggest a reason why this is happending?

Also, on a separate thought...Is there any easy way to log response times
(Page Post times) in a centralized way such as the ASAX file. I assume there
is something in TRACING, but I dont know much about. A little direction
point would be helpful.

Thanks!I found the issue:

I did something like this is the top of my aspx code behind class:

Private UserId As String = Session("UserId")

I change it to

Private UserId As String

and in the form load add:

UserId = Session("UserId")

Apparently, variables are initialized before the session object is
avaialable for use.

"Chad" <chad.dokmanovich@.unisys.comwrote in message
news:f46kr0$isr$1@.trsvr.tr.unisys.com...

Quote:

Originally Posted by

When I visit a specific web page, Request.aspx, for some reason my session
variables are cleared.
>
I noticed that there is a "EnableSessionState" property on the document
object that has three allowed states "True", "false" and "Readonly". I
would assume that by default, if not specified, it is "true".
>
however, I decided to explicitly set it to true to see if it helps.
>
i set it to true in the WebForm. no luck.. Then i realized that it used a
Master Page, so I tried to set the same property there to true.
>
I get the following error message:
>
Error 3 Error parsing attribute 'enablesessionstate': Type
'System.Web.UI.MasterPage' does not have a public property named
'enablesessionstate'.
C:\MyDocs\vss\SMIT\SMIT.PackTrack\PackTrack.NET\BI MasterPage.master 1
>
>
Any idea why I can't set this property or how to prevent the Session
Variable from being cleared. I access the web page using a relative Url,
do not explicitly clear the variable, am not using frames, am using only 1
IE Window.
>
Can anyone suggest a reason why this is happending?
>
Also, on a separate thought...Is there any easy way to log response times
(Page Post times) in a centralized way such as the ASAX file. I assume
there is something in TRACING, but I dont know much about. A little
direction point would be helpful.
>
Thanks!
>
>
>

Monday, March 26, 2012

Session Variable Disappeared

Hello,

I'm using MasterPages to create the layout for all of the pages in my project. Before I converted the Default.aspx page over to the masterpage format this worked.

I have two pages, login.aspx and default.aspx, of course I'm using Forms Authentication. All that works fine, you try to get to default it prompts for login.

Well I used a custom function for the login, it compares data entered to that in a database, if it passed it also returns a variable containing there Trust Level. (String)

At the end of the Button Submit Click but before I redirect the authenticated user to the page they requested I use this code to store trust level in the Session object.

Session("Trust")=TRUST

When the default page loads it shows/hides elements base on thier trust. Now after I've switched over to master pages the code no longer works, it's returning an empty string for Session("Trust")

Example:

<% If Session("Trust") = "Admin" Then %>
Your Access Level is Administrator
<% Else %>
Your Access Level is <% Response.Write(Session("Trust")) %>
<% End If %
I'm loggin in with the Admin Account with a trust of "Admin" and it's just returning an empty string.

Any ideas?What are you using to redirect? If you are not currently, you should be using the RedirectFromLoginPage method.

HTH...
CHris
Thx for the reply,

I figured it out, it was because I deleted the Global.* file. D'OH

Session variable got lost after I switched to another server

The scenario is the following: from the login page I set a session variable
like
Session["USERID"]=3;
Server.transfer("anotherpage.aspx");
In anotherpage.aspx in page load I check to see if that Session is null, if
it's not show a javascript message window with the ID. The funny thing is
that the window is open, ->the variable gets to this page. Good, untill now!
If I click a button from this anotherpage.aspx to
Server.transfer(clients.aspx) and in clients.aspx I try to acces the
Session["USERID"] it says that it is gone (I mean if I cast to string type,
the resulting value is null).
Now the boom (for me) At work (Win 2000) this used to work, however when I
transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
What happens to that variable'Can you write out the value of your session id to make sure it is not
changing between postbacks?
"Vlady" wrote:

> The scenario is the following: from the login page I set a session variabl
e
> like
> Session["USERID"]=3;
> Server.transfer("anotherpage.aspx");
> In anotherpage.aspx in page load I check to see if that Session is null, i
f
> it's not show a javascript message window with the ID. The funny thing is
> that the window is open, ->the variable gets to this page. Good, untill no
w!
> If I click a button from this anotherpage.aspx to
> Server.transfer(clients.aspx) and in clients.aspx I try to acces the
> Session["USERID"] it says that it is gone (I mean if I cast to string type
,
> the resulting value is null).
> Now the boom (for me) At work (Win 2000) this used to work, however when I
> transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
> What happens to that variable'

Session variable got lost after I switched to another server

The scenario is the following: from the login page I set a session variable
like
Session["USERID"]=3;
Server.transfer("anotherpage.aspx");
In anotherpage.aspx in page load I check to see if that Session is null, if
it's not show a javascript message window with the ID. The funny thing is
that the window is open, ->the variable gets to this page. Good, untill now!
If I click a button from this anotherpage.aspx to
Server.transfer(clients.aspx) and in clients.aspx I try to acces the
Session["USERID"] it says that it is gone (I mean if I cast to string type,
the resulting value is null).
Now the boom (for me) At work (Win 2000) this used to work, however when I
transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
What happens to that variable??Can you write out the value of your session id to make sure it is not
changing between postbacks?

"Vlady" wrote:

> The scenario is the following: from the login page I set a session variable
> like
> Session["USERID"]=3;
> Server.transfer("anotherpage.aspx");
> In anotherpage.aspx in page load I check to see if that Session is null, if
> it's not show a javascript message window with the ID. The funny thing is
> that the window is open, ->the variable gets to this page. Good, untill now!
> If I click a button from this anotherpage.aspx to
> Server.transfer(clients.aspx) and in clients.aspx I try to acces the
> Session["USERID"] it says that it is gone (I mean if I cast to string type,
> the resulting value is null).
> Now the boom (for me) At work (Win 2000) this used to work, however when I
> transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
> What happens to that variable??

Session variable is not transferred to an asp page?

I have a asp.net project with all major pages written in aspx, but I want to keep an existing asp page in the same directory as the aspx files. But when the asp page gets loaded, the session variable is not recognized. Is this the case and why?To be specific, when I load the asp.net app using the address of http://localhost/myproj/ it works fine, and the asp page could read the session variable assigned by an aspx page. But if I use my computer name, say http://keystrokes_win2k/myproj/ then it doesn't work.

Any ideas?
No, the ASP and ASP.NET sessions are two separate objects that do not share their data. There are some third party session objects that you can use to communicate between the two environments, though.
What is the third party session object, please provide some lead ?

Session Variable Madness

Here's one that has been stumping people:

I'm writing in ASPX with VB.NET

On the login page I set the entered usename text to a session
variable.
************************************************** **********************
Private Sub lbtnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbtnSubmit.Click
Dim bolLogin As Boolean

If Page.IsValid Then
Session("ctc_username") = txtUsername.Text.ToUpper()
Response.Redirect("acchist.aspx")
End If
End Sub
************************************************** ***********************
On the next/called page "acchist.aspx" I assign the session variable
to the text of lblUser.
************************************************** ***********************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Page.IsPostBack Then

Else
lblUser.Text = Session("ctc_username")
End If
End Sub
************************************************** ***********************
Here's where the strange behavior starts. In IE6 the session variable
will display in lblUser on the page load. However, if the page is
refreshed the session variable disappears from both lblUser and the
page trace. If the page is repeatedly refreshed the session variable
will begin to alternate as there or not. In Netscape 7.0 the first
time that the called page loads the session variable doesn't appear
and then begins with the smae behavior on repeated refresh.

You can check it out at the following address:
www5dev.nau.edu/ctc/registration/login.aspx
Put in any username and password.

Does anyone know what is causing this and/or how to get the session
variable to remain consistent?

Thanks,
Todd Bohlander
Ancillary Systems Development
Information Technology Services
Northern Arizona UniversityTodd,

typically a refresh means that you are no longer in the same session, and so
results in the cache being flushed. why it's reappearing after than I'm not
sure.

Why not assign the name to a text box or a label that has the
EnableViewState enabled (default) and set them visible=false if you don't
want to see them. This should provide more consistency in this case.

hope this helps.
Dan.

"Todd" <rtb22@.dana.ucc.nau.edu> wrote in message
news:e7dd1133.0401210844.65048300@.posting.google.c om...
Here's one that has been stumping people:

I'm writing in ASPX with VB.NET

On the login page I set the entered usename text to a session
variable.
************************************************** **********************
Private Sub lbtnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbtnSubmit.Click
Dim bolLogin As Boolean

If Page.IsValid Then
Session("ctc_username") = txtUsername.Text.ToUpper()
Response.Redirect("acchist.aspx")
End If
End Sub
************************************************** ***********************
On the next/called page "acchist.aspx" I assign the session variable
to the text of lblUser.
************************************************** ***********************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Page.IsPostBack Then

Else
lblUser.Text = Session("ctc_username")
End If
End Sub
************************************************** ***********************
Here's where the strange behavior starts. In IE6 the session variable
will display in lblUser on the page load. However, if the page is
refreshed the session variable disappears from both lblUser and the
page trace. If the page is repeatedly refreshed the session variable
will begin to alternate as there or not. In Netscape 7.0 the first
time that the called page loads the session variable doesn't appear
and then begins with the smae behavior on repeated refresh.

You can check it out at the following address:
www5dev.nau.edu/ctc/registration/login.aspx
Put in any username and password.

Does anyone know what is causing this and/or how to get the session
variable to remain consistent?

Thanks,
Todd Bohlander
Ancillary Systems Development
Information Technology Services
Northern Arizona University
Are you using web farm or web gardening? If so what type of session state
are you using?

"Todd" <rtb22@.dana.ucc.nau.edu> wrote in message
news:e7dd1133.0401210844.65048300@.posting.google.c om...
> Here's one that has been stumping people:
> I'm writing in ASPX with VB.NET
> On the login page I set the entered usename text to a session
> variable.
> ************************************************** **********************
> Private Sub lbtnSubmit_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles lbtnSubmit.Click
> Dim bolLogin As Boolean
> If Page.IsValid Then
> Session("ctc_username") = txtUsername.Text.ToUpper()
> Response.Redirect("acchist.aspx")
> End If
> End Sub
> ************************************************** ***********************
> On the next/called page "acchist.aspx" I assign the session variable
> to the text of lblUser.
> ************************************************** ***********************
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> If Page.IsPostBack Then
> Else
> lblUser.Text = Session("ctc_username")
> End If
> End Sub
> ************************************************** ***********************
> Here's where the strange behavior starts. In IE6 the session variable
> will display in lblUser on the page load. However, if the page is
> refreshed the session variable disappears from both lblUser and the
> page trace. If the page is repeatedly refreshed the session variable
> will begin to alternate as there or not. In Netscape 7.0 the first
> time that the called page loads the session variable doesn't appear
> and then begins with the smae behavior on repeated refresh.
> You can check it out at the following address:
> www5dev.nau.edu/ctc/registration/login.aspx
> Put in any username and password.
> Does anyone know what is causing this and/or how to get the session
> variable to remain consistent?
> Thanks,
> Todd Bohlander
> Ancillary Systems Development
> Information Technology Services
> Northern Arizona University

Session variable problem

Hi,
Please help me with the following:
In login.aspx page:
Session("accessGranted") = 1
Response.Write("<script>window.open(""userpage.aspx"", ""User"");</script>")
In userpage.aspx:
<body>
<script language="vb" runat="server">
Sub Page_Load(source as Object, e as EventArgs)
if Session("accessGranted") is nothing then
response.redirect("login_failed.htm")
end if
end sub
</script>
Problem:
Every time a user logs in the first time the userpage.aspx doesn't see the S
ession and kicks the user out. However, when you repeat the login, the page
sees the Session. It looks as if the session were created then the userpage
opens - can it be? What s
hould I do to avoid this problem?
Thanks,
Alex Fimine
alex@dotnet.itags.org.agfconsulting.com> It looks as if the session were created then the userpage opens
According to your code, the Session variable is initialized BEFORE userpage
opens:

> In login.aspx page:
> Session("accessGranted") = 1
> Response.Write("<script>window.open(""userpage.aspx"",
""User"");</script>")
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Alex Fimine" <AlexFimine@.discussions.microsoft.com> wrote in message
news:926DE728-127C-47D5-ADBD-F517C726D2A2@.microsoft.com...
> Hi,
> Please help me with the following:
> In login.aspx page:
> Session("accessGranted") = 1
> Response.Write("<script>window.open(""userpage.aspx"",
""User"");</script>")
>
> In userpage.aspx:
> <body>
> <script language="vb" runat="server">
> Sub Page_Load(source as Object, e as EventArgs)
> if Session("accessGranted") is nothing then
> response.redirect("login_failed.htm")
> end if
> end sub
> </script>
> Problem:
> Every time a user logs in the first time the userpage.aspx doesn't see the
Session and kicks the user out. However, when you repeat the login, the page
sees the Session. It looks as if the session were created then the userpage
opens - can it be? What should I do to avoid this problem?
>
> Thanks,
> Alex Fimine
> alex@.agfconsulting.com
Kevin, I know that according to the code the session is created BEFORE - tha
t, not surprisingly, was my intention. However, as I explained, there is a p
roblem with that.
"Kevin Spencer" wrote:

> According to your code, the Session variable is initialized BEFORE userpag
e
> opens:
>
> ""User"");</script>")
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "Alex Fimine" <AlexFimine@.discussions.microsoft.com> wrote in message
> news:926DE728-127C-47D5-ADBD-F517C726D2A2@.microsoft.com...
> ""User"");</script>")
> Session and kicks the user out. However, when you repeat the login, the pa
ge
> sees the Session. It looks as if the session were created then the userpa
ge
> opens - can it be? What should I do to avoid this problem?
>
>

Saturday, March 24, 2012

Session variable problem

Hi,

Please help me with the following:

In login.aspx page:

Session("accessGranted") = 1
Response.Write("<script>window.open(""userpage.aspx"", ""User"");</script>")

In userpage.aspx:

<body>
<script language="vb" runat="server"
Sub Page_Load(source as Object, e as EventArgs)

if Session("accessGranted") is nothing then
response.redirect("login_failed.htm")
end if

end sub

</script
Problem:
Every time a user logs in the first time the userpage.aspx doesn't see the Session and kicks the user out. However, when you repeat the login, the page sees the Session. It looks as if the session were created then the userpage opens - can it be? What should I do to avoid this problem?

Thanks,

Alex Fimine
alex@dotnet.itags.org.agfconsulting.com> It looks as if the session were created then the userpage opens

According to your code, the Session variable is initialized BEFORE userpage
opens:

> In login.aspx page:
> Session("accessGranted") = 1
> Response.Write("<script>window.open(""userpage.aspx"",
""User"");</script>")

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Alex Fimine" <AlexFimine@.discussions.microsoft.com> wrote in message
news:926DE728-127C-47D5-ADBD-F517C726D2A2@.microsoft.com...
> Hi,
> Please help me with the following:
> In login.aspx page:
> Session("accessGranted") = 1
> Response.Write("<script>window.open(""userpage.aspx"",
""User"");</script>")
>
> In userpage.aspx:
> <body>
> <script language="vb" runat="server">
> Sub Page_Load(source as Object, e as EventArgs)
> if Session("accessGranted") is nothing then
> response.redirect("login_failed.htm")
> end if
> end sub
> </script>
> Problem:
> Every time a user logs in the first time the userpage.aspx doesn't see the
Session and kicks the user out. However, when you repeat the login, the page
sees the Session. It looks as if the session were created then the userpage
opens - can it be? What should I do to avoid this problem?
>
> Thanks,
> Alex Fimine
> alex@.agfconsulting.com
Kevin, I know that according to the code the session is created BEFORE - that, not surprisingly, was my intention. However, as I explained, there is a problem with that.

"Kevin Spencer" wrote:

> > It looks as if the session were created then the userpage opens
> According to your code, the Session variable is initialized BEFORE userpage
> opens:
> > In login.aspx page:
> > Session("accessGranted") = 1
> > Response.Write("<script>window.open(""userpage.aspx"",
> ""User"");</script>")
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "Alex Fimine" <AlexFimine@.discussions.microsoft.com> wrote in message
> news:926DE728-127C-47D5-ADBD-F517C726D2A2@.microsoft.com...
> > Hi,
> > Please help me with the following:
> > In login.aspx page:
> > Session("accessGranted") = 1
> > Response.Write("<script>window.open(""userpage.aspx"",
> ""User"");</script>")
> > In userpage.aspx:
> > <body>
> > <script language="vb" runat="server">
> > Sub Page_Load(source as Object, e as EventArgs)
> > if Session("accessGranted") is nothing then
> > response.redirect("login_failed.htm")
> > end if
> > end sub
> > </script>
> > Problem:
> > Every time a user logs in the first time the userpage.aspx doesn't see the
> Session and kicks the user out. However, when you repeat the login, the page
> sees the Session. It looks as if the session were created then the userpage
> opens - can it be? What should I do to avoid this problem?
> > Thanks,
> > Alex Fimine
> > alex@.agfconsulting.com
>

Session variable scope in a Load Balanced environment

I have the following scenario in a true load balanced environment (without
sticky sessions):
There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.Property1 = "Property1";
orderInfo.Property2 = "Property2" Session["orderInfo"] =
orderInfo;
Response.Redirect("Page2.aspx");
}On Page2.aspx, on the Page_Load event, I retrieve the object from the
Session variable and put it in a OrderInfo object and then remove the
session variable. The code looks similar to below:
void Page_Load(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = (OrderInfo)Session["orderInfo"];
Session.Remove("orderInfo");
}My understanding is - creating the object, putting it in a Session
variable, redirecting to another page and retrieval of the object in the
second page - all these happens in one server call. I don't care if the
Session variable is lost after this call. That is the reason I remove the
variable from session state.
My question is - are there any chances that the Session variable will lose
its value in the above scenario because of load balancing?
Any help will be appriciated.
Thanks!On Wed, 28 Dec 2005 11:57:17 +0530, Vidyadhar Joshi wrote:

> I have the following scenario in a true load balanced environment (without
> sticky sessions):
> There are 2 ASPX pages. I want to pass an object from the first page to th
e
> second page. On the btnContinue_Click event of Page1.aspx, I create the
> object and store it in a session variable. The next statement would be
> Response.Redirect("Page2.aspx"). The code appears like this:
> private void btnContinue_Click(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo.Property1 = "Property1";
> orderInfo.Property2 = "Property2" Session["orderInfo"] =
> orderInfo;
> Response.Redirect("Page2.aspx");
> }On Page2.aspx, on the Page_Load event, I retrieve the object from the
> Session variable and put it in a OrderInfo object and then remove the
> session variable. The code looks similar to below:
> void Page_Load(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo = (OrderInfo)Session["orderInfo"];
> Session.Remove("orderInfo");
> }My understanding is - creating the object, putting it in a Session
> variable, redirecting to another page and retrieval of the object in the
> second page - all these happens in one server call. I don't care if the
> Session variable is lost after this call. That is the reason I remove the
> variable from session state.
> My question is - are there any chances that the Session variable will lose
> its value in the above scenario because of load balancing?
> Any help will be appriciated.
> Thanks!
In my experience, load balancing (without sticky), will create problems
for you.
You will also have problems with the Session being dumped due to timeout,
restarts of the server, etc.

Session variable scope in a Load Balanced environment

I have the following scenario in a true load balanced environment (without
sticky sessions):

There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.Property1 = "Property1";
orderInfo.Property2 = "Property2" Session["orderInfo"] =
orderInfo;
Response.Redirect("Page2.aspx");
}On Page2.aspx, on the Page_Load event, I retrieve the object from the
Session variable and put it in a OrderInfo object and then remove the
session variable. The code looks similar to below:
void Page_Load(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = (OrderInfo)Session["orderInfo"];
Session.Remove("orderInfo");
}My understanding is - creating the object, putting it in a Session
variable, redirecting to another page and retrieval of the object in the
second page - all these happens in one server call. I don't care if the
Session variable is lost after this call. That is the reason I remove the
variable from session state.

My question is - are there any chances that the Session variable will lose
its value in the above scenario because of load balancing?

Any help will be appriciated.

Thanks!On Wed, 28 Dec 2005 11:57:17 +0530, Vidyadhar Joshi wrote:

> I have the following scenario in a true load balanced environment (without
> sticky sessions):
> There are 2 ASPX pages. I want to pass an object from the first page to the
> second page. On the btnContinue_Click event of Page1.aspx, I create the
> object and store it in a session variable. The next statement would be
> Response.Redirect("Page2.aspx"). The code appears like this:
> private void btnContinue_Click(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo.Property1 = "Property1";
> orderInfo.Property2 = "Property2" Session["orderInfo"] =
> orderInfo;
> Response.Redirect("Page2.aspx");
> }On Page2.aspx, on the Page_Load event, I retrieve the object from the
> Session variable and put it in a OrderInfo object and then remove the
> session variable. The code looks similar to below:
> void Page_Load(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo = (OrderInfo)Session["orderInfo"];
> Session.Remove("orderInfo");
> }My understanding is - creating the object, putting it in a Session
> variable, redirecting to another page and retrieval of the object in the
> second page - all these happens in one server call. I don't care if the
> Session variable is lost after this call. That is the reason I remove the
> variable from session state.
> My question is - are there any chances that the Session variable will lose
> its value in the above scenario because of load balancing?
> Any help will be appriciated.
> Thanks!
In my experience, load balancing (without sticky), will create problems
for you.
You will also have problems with the Session being dumped due to timeout,
restarts of the server, etc.

Session Variable update problem

I have two ASPX in my testproject :
1:
In the Page_load there is :
If Not Me.IsPostBack Then
Dim tfm
tfm = 30
Session("tfm") = tfm
Dim popupScript As String = "<script
language='javascript'>alert('Yes');</script>"
Page.RegisterStartupScript("PopupScript", popupScript)
End If
and there is the function that should change to value of tfm
Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rlist1.CheckedChanged
Dim tfm
tfm = Session("tfm")
tfm = 55
Session("tfm") = tfm
lblTotaal.Text = "gert" & Str(Session("tfm"))
End Sub
What happens : the lblTotaal will show me the 55 instead of the 30. But in
the next aspx the following returns the 30 again
If Not Me.IsPostBack Then
Dim tfm
tfm = Session("tfm")
Label1.Text = Str(tfm)
end if
PLEASE HELP ! What am I doing wrong,Gert:
This may be a ViewState issue, where the view state is changing the value of
the label to the old value. One suggestion would be to set the
EnableViewState property of the label to false.
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"gce" <gceng2@.hotmail.com> wrote in message
news:d5hhqu$7a1$1@.news1.zwoll1.ov.home.nl...
> I have two ASPX in my testproject :
> 1:
> In the Page_load there is :
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = 30
> Session("tfm") = tfm
> Dim popupScript As String = "<script
> language='javascript'>alert('Yes');</script>"
> Page.RegisterStartupScript("PopupScript", popupScript)
> End If
> and there is the function that should change to value of tfm
> Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles rlist1.CheckedChanged
> Dim tfm
> tfm = Session("tfm")
> tfm = 55
> Session("tfm") = tfm
> lblTotaal.Text = "gert" & Str(Session("tfm"))
> End Sub
>
> What happens : the lblTotaal will show me the 55 instead of the 30. But in
> the next aspx the following returns the 30 again
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = Session("tfm")
> Label1.Text = Str(tfm)
> end if
> PLEASE HELP ! What am I doing wrong,
>

Session Variable update problem

I have two ASPX in my testproject :

1:

In the Page_load there is :

If Not Me.IsPostBack Then
Dim tfm
tfm = 30
Session("tfm") = tfm
Dim popupScript As String = "<script
language='javascript'>alert('Yes');</script>"
Page.RegisterStartupScript("PopupScript", popupScript)
End If

and there is the function that should change to value of tfm

Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rlist1.CheckedChanged
Dim tfm
tfm = Session("tfm")
tfm = 55
Session("tfm") = tfm
lblTotaal.Text = "gert" & Str(Session("tfm"))
End Sub

What happens : the lblTotaal will show me the 55 instead of the 30. But in
the next aspx the following returns the 30 again

If Not Me.IsPostBack Then
Dim tfm
tfm = Session("tfm")
Label1.Text = Str(tfm)
end if

PLEASE HELP ! What am I doing wrong,Gert:

This may be a ViewState issue, where the view state is changing the value of
the label to the old value. One suggestion would be to set the
EnableViewState property of the label to false.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.

"gce" <gceng2@.hotmail.com> wrote in message
news:d5hhqu$7a1$1@.news1.zwoll1.ov.home.nl...
> I have two ASPX in my testproject :
> 1:
> In the Page_load there is :
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = 30
> Session("tfm") = tfm
> Dim popupScript As String = "<script
> language='javascript'>alert('Yes');</script>"
> Page.RegisterStartupScript("PopupScript", popupScript)
> End If
> and there is the function that should change to value of tfm
> Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles rlist1.CheckedChanged
> Dim tfm
> tfm = Session("tfm")
> tfm = 55
> Session("tfm") = tfm
> lblTotaal.Text = "gert" & Str(Session("tfm"))
> End Sub
>
> What happens : the lblTotaal will show me the 55 instead of the 30. But in
> the next aspx the following returns the 30 again
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = Session("tfm")
> Label1.Text = Str(tfm)
> end if
> PLEASE HELP ! What am I doing wrong,

Session Variable Values Across HTTP/HTTPS

It appears that I'm losing values for session variables when I move from a
page like http://www.my_site.com/catalog.aspx to
https://www50.ssldomain.com/my_site/login.aspx and vice versa.
Are session variables suppose to lose values across different domain names?
The www50.ssldomain.com is hosted by the same webhost. It's just how they
handle their SSL certificate.
Help! Thanks for any help.
KenAcross domains? Yes. What happens, client side, is there are two server
cookies sent. This is quite normal and part of the "security" built into
browsers.
If you have a persistant store (database, for example), store values in the
database. On the same machine, you can sometimes get away with equivalent
machine keys, but cross domain is still a difficulty. The persistant store
overcomes this, as you can look up values as a user moves from site to site.
This is best if you go to cookieless authentication (which munges in the
session key).
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"MisterKen" wrote:

> It appears that I'm losing values for session variables when I move from a
> page like http://www.my_site.com/catalog.aspx to
> https://www50.ssldomain.com/my_site/login.aspx and vice versa.
> Are session variables suppose to lose values across different domain names
?
> The www50.ssldomain.com is hosted by the same webhost. It's just how they
> handle their SSL certificate.
> Help! Thanks for any help.
> Ken
Thanks for the clarification.
Do you know of a webpage that might demonstrate this?
"Cowboy (Gregory A. Beamer) - MVP" wrote:
> Across domains? Yes. What happens, client side, is there are two server
> cookies sent. This is quite normal and part of the "security" built into
> browsers.
> If you have a persistant store (database, for example), store values in th
e
> database. On the same machine, you can sometimes get away with equivalent
> machine keys, but cross domain is still a difficulty. The persistant store
> overcomes this, as you can look up values as a user moves from site to sit
e.
> This is best if you go to cookieless authentication (which munges in the
> session key).
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ***************************
> Think Outside the Box!
> ***************************
>
> "MisterKen" wrote:
>

Session Variable Values Across HTTP/HTTPS

It appears that I'm losing values for session variables when I move from a
page like http://www.my_site.com/catalog.aspx to
https://www50.ssldomain.com/my_site/login.aspx and vice versa.

Are session variables suppose to lose values across different domain names?

The www50.ssldomain.com is hosted by the same webhost. It's just how they
handle their SSL certificate.

Help! Thanks for any help.

KenAcross domains? Yes. What happens, client side, is there are two server
cookies sent. This is quite normal and part of the "security" built into
browsers.

If you have a persistant store (database, for example), store values in the
database. On the same machine, you can sometimes get away with equivalent
machine keys, but cross domain is still a difficulty. The persistant store
overcomes this, as you can look up values as a user moves from site to site.
This is best if you go to cookieless authentication (which munges in the
session key).

--

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"MisterKen" wrote:

> It appears that I'm losing values for session variables when I move from a
> page like http://www.my_site.com/catalog.aspx to
> https://www50.ssldomain.com/my_site/login.aspx and vice versa.
> Are session variables suppose to lose values across different domain names?
> The www50.ssldomain.com is hosted by the same webhost. It's just how they
> handle their SSL certificate.
> Help! Thanks for any help.
> Ken
Thanks for the clarification.

Do you know of a webpage that might demonstrate this?

"Cowboy (Gregory A. Beamer) - MVP" wrote:

> Across domains? Yes. What happens, client side, is there are two server
> cookies sent. This is quite normal and part of the "security" built into
> browsers.
> If you have a persistant store (database, for example), store values in the
> database. On the same machine, you can sometimes get away with equivalent
> machine keys, but cross domain is still a difficulty. The persistant store
> overcomes this, as you can look up values as a user moves from site to site.
> This is best if you go to cookieless authentication (which munges in the
> session key).
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ***************************
> Think Outside the Box!
> ***************************
>
> "MisterKen" wrote:
> > It appears that I'm losing values for session variables when I move from a
> > page like http://www.my_site.com/catalog.aspx to
> > https://www50.ssldomain.com/my_site/login.aspx and vice versa.
> > Are session variables suppose to lose values across different domain names?
> > The www50.ssldomain.com is hosted by the same webhost. It's just how they
> > handle their SSL certificate.
> > Help! Thanks for any help.
> > Ken

Thursday, March 22, 2012

Session Variables

Hi,

I am using .asp and .aspx files together on the same application. I would like to use Session variables with a .asp file. Will this work? Can I use Session variables with a .asp and .asax file? Or will global .asa work?

I haven't started coding yet. I thought I would save myself some time and ask first. Any suggestions are appreciated.

Thanks,

MikeHi there,

There are several articles our there that explain the tweeks you need to do to share sessions between asp and asp.net... here are some of them:

http://www.eggheadcafe.com/articles/20021207.asp

http://www.asp101.com/articles/sidney/sharingsessionstate/default.asp

I hope this helps,

Covo

Session Variables

I have a website I wrote where I store information that I need from page to page in session variables. I set the variable in the global.aspx to "". Then in my code I simply reference it like: Session("CheckType") = "DIRECT"

Now would anyone know why this would sometimes not keep? Some of my session variables work fine and keep their values from page to page. There is one however where I can assign a value on one page for it and it never keeps, so when I reference the value on another page it doesn't work. Ideas?

Thanks!It won't stay in memory if the session times out. Is that what's happening?