473,695 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 recordinformati on) 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 2522
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, "catweezle2 010" <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 recordinformati on) 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_VNA ME")=""
Session("KD_NAM E")=""
Session("STADT" )=""
Session("PLZ")= ""
Session("STRASS E")=""

If Session.IsNewSe ssion Then
TextBox1.value= "neu"
else
if ispostback then
Session("Anwend ername") = TextBoxLogin.va lue
TextBox1.value= Session("Anwend ername")
response.redire ct("suche.aspx" )
else
TextBox1.value= Session("Anwend ername")
Session("Anwend ername") = TextBox1.value
response.redire ct("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.IsNewSe ssion Then
response.redire ct("default.asp x")
else
dataSet
end if
end sub

public sub DataSet()
Session("KD_VNA ME")=""
Session("KD_NAM E")=""
Session("STADT" )=""
Session("PLZ")= ""
Session("STRASS E")=""
Datagrid1.DataB ind()
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.IDa taReader
Dim connectionStrin g As String = "Data Source=mssql;In itial
Catalog=DB;User Id=huser;Passwo rd=passw;Connec t Timeout=15;Netw ork
Library=dbmssoc n;"
Dim dbConnection As System.Data.IDb Connection = New
System.Data.Sql Client.SqlConne ction(connectio nString)
Dim queryString As String = ""
Dim dbCommand As System.Data.IDb Command = New
System.Data.Sql Client.SqlComma nd

if TextBox_Name.te xt <> "" then
if queryString <> "" then
queryString = querystring & " and "
end if
queryString = queryString & "[KD_NAME] like N'" & TextBox_Name.te xt
& "%' "
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.Comma ndText = queryString
dbCommand.Conne ction = dbConnection
dbConnection.Op en
Dim dataReader As System.Data.IDa taReader =
dbCommand.Execu teReader(System .Data.CommandBe havior.CloseCon nection)
Return dataReader
dataReader.clos e
dbConnection.cl ose
connectionStrin g = ""
queryString = ""
end function

call.aspx

public sub ButtonEnde_Clic k(sender As Object, e As EventArgs)
response.redire ct("default.asp x")
'response.redir ect("suche.aspx ")
end sub


Any idea?

Nov 19 '05 #3
One thing you may want to try is to use:

Response.Redire ct("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, "catweezle2 010" <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_VNA ME")=""
Session("KD_NAM E")=""
Session("STADT" )=""
Session("PLZ")= ""
Session("STRASS E")=""

If Session.IsNewSe ssion Then
TextBox1.value= "neu"
else
if ispostback then
Session("Anwend ername") = TextBoxLogin.va lue
TextBox1.value= Session("Anwend ername")
response.redire ct("suche.aspx" )
else
TextBox1.value= Session("Anwend ername")
Session("Anwend ername") = TextBox1.value
response.redire ct("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.IsNewSe ssion Then
response.redire ct("default.asp x")
else
dataSet
end if
end sub

public sub DataSet()
Session("KD_VNA ME")=""
Session("KD_NAM E")=""
Session("STADT" )=""
Session("PLZ")= ""
Session("STRASS E")=""
Datagrid1.DataB ind()
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.IDa taReader
Dim connectionStrin g As String = "Data Source=mssql;In itial
Catalog=DB;Use r Id=huser;Passwo rd=passw;Connec t Timeout=15;Netw ork
Library=dbmsso cn;"
Dim dbConnection As System.Data.IDb Connection = New
System.Data.Sq lClient.SqlConn ection(connecti onString)
Dim queryString As String = ""
Dim dbCommand As System.Data.IDb Command = New
System.Data.Sq lClient.SqlComm and

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

queryString = "SELECT [View_Such].* FROM [View_Such] WHERE (" &
queryString & ")"
dbCommand.Comma ndText = queryString
dbCommand.Conne ction = dbConnection
dbConnection.Op en
Dim dataReader As System.Data.IDa taReader =
dbCommand.Exec uteReader(Syste m.Data.CommandB ehavior.CloseCo nnection)
Return dataReader
dataReader.clos e
dbConnection.cl ose
connectionStrin g = ""
queryString = ""
end function

call.aspx

public sub ButtonEnde_Clic k(sender As Object, e As EventArgs)
response.redire ct("default.asp x")
'response.redir ect("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
2847
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 client browser when the app is accessed the session variable returns null inspite of a value being already set. I have checked the IIS enable session state settings. When i use the server machine as client and access the app as localhost then...
0
2096
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 Session Data lost randomly and Session State sometime expired early. I pretty run out the solution to fix this problem. Althoug we use Web Farm but we have Sticky IP to let user request go to the same server all the time. We turn off the Web...
1
2335
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 session variable is not same as what I set in the previous page. My session data is lost. This is happening very frequently in IE6.0 sp2 and very less frequently in IE6.0 sp1.
1
737
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 find one? Thanks Werner P.S. Somehow I did not manage to do a followup in Googles newsgroups.
2
2009
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 project which used a session management dll to discover what was wrong in my project. This web project has two pages, one send to the other a variable with session state and the other changes this one, shown in a label, with each postback, well,...
0
1477
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 number. that in turn goes to the next page where its being picked up by the php code and put into the Global Variable. the page uses the variables with no problem and you can select a link to go onto the next page where the number is being...
11
3647
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 method has the WebMethodAttribute.EnableSession set to true. When I run the test page the session is maintained. However, using a console application, in between setting the string value and attempting to
9
1821
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" name=".ASPXAUTH" path="/"
2
1195
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, Membership methods are called to obtain the ID, that value is stored in the session state, and that value is then returned. This appears to work fine. However, I'm now giving users of one type the ability to "impersonate" another. In this case,...
0
8617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8971
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...
0
7650
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6483
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
4332
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
4570
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
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.