473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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?

Nov 19 '05 #1
3 2499
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" <ca***********@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?


Nov 19 '05 #2
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?

Nov 19 '05 #3
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/archiv...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" <ca***********@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(connectionStr ing)
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.CommandBehavi or.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?


Nov 19 '05 #4

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

Similar topics

3
by: Microsoft | last post by:
I am using Session variables in my ASP application. I have tested the application on a Win2k professional and it works fine. When the same web app is installed on a win2k advanced server from the...
0
by: CJ | last post by:
Hi We have Session Data lost randomly and Session State expired early. Our Intranet Application uses Window Server 2003 and .Net Framework 1.1. We set Session Time out to 60 minutes. but user...
1
by: ramsankar | last post by:
Hi All, When viewing my php page using IE6.0, I am losing my session data. In the first page I am setting a value to the session variable. In the next page "SOME TIME" the value of the...
1
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can...
2
by: Tomas Martinez | last post by:
Hi, Well, my problem is so simple as it says in the subjet but very frustrating also. I have a project and it is losing the session variables with each postback, so I downloaded from the web a...
0
by: Aarchaic | last post by:
Hello i have problem my session variables seem to disapear as i go along i've created this code to ilustrate whats happening First off i just post 3 detials like a name a age and a favourite...
11
by: Glenn | last post by:
Hi I've been experimenting with managing state using the Session object. I've created a simple WS with a couple of methods, one which sets a string value, another that retrieves it. Each...
9
by: gnewsgroup | last post by:
I am using forms authentication for my web application. In web.config, I have this: <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="120"...
2
by: Jonathan Wood | last post by:
I have a static class member that returns the ID of the current user. When it is called, it checks if the value is already stored in the session state, if it is, that value is returned. Otherwise,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.