468,132 Members | 1,553 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,132 developers. It's quick & easy.

Loss of values in session

Chaps.

We are working with SQL-Server based Sessions in the following environemtn:

Win-Server 2K3 incl. IIS, Dot Net Framework 1.1, SQL2K SP3a, German.

We are defining a Session-Variable named keyword inside asp.net website. At
the end of the Website we are writing this variable again to test if the
value still exists to the output-buffer.

The variable-value is set at the end of the page. When we now press enter in
a input-form-field on the website which results in submitting the page
automatically, Session-variable which is written to output-buffer directly
after variable definition-part, is empty.

Session-Variable is set with the value of a String().

Why is that? Is there any clue on this?

Steve
Nov 19 '05 #1
8 1484
Hi Steve,

Welcome to ASPNET newsgroup.
From your description, you're encountering some probems when using
SqlServer SessionState in asp.net application. You found the data you
stored not exist when try retrieving it later, yes?

As for this problem, I'm still wondering on something you mentioned:

1.Does the "At the end of the Website" you mentioned means the end of each
Page Request? If so , would you provide some more detailed info on the code
logic such as in what event do you do that work and some code snippet will
helps more. If you can provide a complete page and the code snippet, we
can try performing some tests on ourside.

2. As you're using the SQLserver session, have you also test through InProc
session to see whether the problem also occurs. This can help us confirm
whether this is a SqlServer mode related issue.

If there're any other info, please feel free to post here, also. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 19 '05 #2
Hi Steven,

thanks for this fast answer.
From your description, you're encountering some probems when using
SqlServer SessionState in asp.net application. You found the data you
stored not exist when try retrieving it later, yes? Yes, but there are several Session-Variables which persist, so it is
not a general Problem in setting values to Session-Variables.
I thought of perhaps a limit on the count of usable session-variables,
or a memory limit.
As for this problem, I'm still wondering on something you mentioned:

1.Does the "At the end of the Website" you mentioned means the end of
each
Page Request? If so , would you provide some more detailed info on the
code
logic such as in what event do you do that work and some code snippet
will
helps more. If you can provide a complete page and the code snippet, we
can try performing some tests on ourside. I can't provide you with the complete page now, cause it is a webshop of a
customer as for you would need a login which can't be created for the
moment.

here is the relevant code which defines the session-vars and prints 'em
out:

Session.Timeout = 15
Dim post_vars As New Hashtable
for i As Integer = 0 to (Request.Form.Count - 1)
post_vars.Add(Request.Form.GetKey(i), Request.Form(i).ToString)
next

...

Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword") &
"<br>")

...

if IsNothing(Session("keyword")) = false then
if post_vars.Item("keyword") <> Session("keyword") then
Session("keyword") = post_vars.Item("keyword")
end if
else
Session.Add("keyword", post_vars.Item("keyword"))
end if
Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword") &
"<br>")

...

</html>
<%
Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword")
& "<br>")
%>

2. As you're using the SQLserver session, have you also test through
InProc
session to see whether the problem also occurs. This can help us confirm
whether this is a SqlServer mode related issue.


No, not tested till now. Will test this this afternoon and write another
answert on this post
with the result though.
Perhaps there is already sth in this post that can help you with my
problem.
Thanks for now,

Steve
Nov 19 '05 #3
Hi Steve,

Thanks for your code snippet, now I got that your "end of web app" means
the below code block after </html> tag, yes?

</html>
<%
Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword")
& "<br>")
%>
Also, as for the former code period
====================
Session.Timeout = 15
Dim post_vars As New Hashtable
for i As Integer = 0 to (Request.Form.Count - 1)
post_vars.Add(Request.Form.GetKey(i), Request.Form(i).ToString)
next

...

Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword") &
"<br>")

...

if IsNothing(Session("keyword")) = false then
if post_vars.Item("keyword") <> Session("keyword") then
Session("keyword") = post_vars.Item("keyword")
end if
else
Session.Add("keyword", post_vars.Item("keyword"))
end if
Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword") &
"<br>")

...
====================

are they also put in the aspx inline directly or in code behind page
events? This is very important since the ASP.NET has different page object
model from classic ASP and all the code in aspx template(inline) will be
compiled into a single method and be called as part of the PAGE's render
progress.

Also, you don't need to provide me the complete code of your page. I'm just
wondering a very simple page with very simple code page which can just
represent the problem you encountered. So Would you try buiding a dummy
page ?

Thanks,

Steven Cheng
Microsoft Online Support

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

Nov 19 '05 #4
Hello Steven,

yes all of the code in this case is inline.
I tried InProc-Session-Handling now. With InProc everything works as
expected.
So with InProc there is no loss of values in Sessions or so.

If you want to have a login to the webshop, please tell me where to send
the
login-data to, so that you can login and see what happens. A description
on how
you can experience the problem will be send with the login-data though.
Thanks for your help in Advance.
Steve

Am Mon, 30 May 2005 10:57:19 +0200 schrieb Steven Cheng[MSFT]
<v-******@online.microsoft.com>:
Hi Steve,

Thanks for your code snippet, now I got that your "end of web app" means
the below code block after </html> tag, yes?

</html>
<%
Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword")
& "<br>")
%>
Also, as for the former code period
====================
Session.Timeout = 15
Dim post_vars As New Hashtable
for i As Integer = 0 to (Request.Form.Count - 1)
post_vars.Add(Request.Form.GetKey(i), Request.Form(i).ToString)
next

...

Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword")
&
"<br>")

...

if IsNothing(Session("keyword")) = false then
if post_vars.Item("keyword") <> Session("keyword") then
Session("keyword") = post_vars.Item("keyword")
end if
else
Session.Add("keyword", post_vars.Item("keyword"))
end if
Response.Write(Session("keyword") & " <-> " & post_vars.Item("keyword")
&
"<br>")

...
====================

are they also put in the aspx inline directly or in code behind page
events? This is very important since the ASP.NET has different page
object
model from classic ASP and all the code in aspx template(inline) will be
compiled into a single method and be called as part of the PAGE's render
progress.

Also, you don't need to provide me the complete code of your page. I'm
just
wondering a very simple page with very simple code page which can just
represent the problem you encountered. So Would you try buiding a dummy
page ?

Thanks,

Steven Cheng
Microsoft Online Support

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


--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
Nov 19 '05 #5
Thanks Steve,

Before we looking into depth of your code logic or your web shop, I'd like
to confirm whether this is a environment specific problem. Based on my
local test, I can read and update Sessionstate(sqlserver mode) in the aspx
inline code. Here is my test page:

==================================
<HTML>
<HEAD>
<title>inlineSessionProcess</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<%
Response.Write("<br>FirstLoop:");
foreach(string key in Session.Keys)
{
Response.Write(string.Format("<br/>{0}: {1}", key, Session[key]));
}

%>
<%
if(Request.Form["override"] != null)
{
Session["txt1"] = Request.Form["txt1"];
Session["txt2"] = Request.Form["txt2"];
Session["txt3"] = Request.Form["txt3"];
Session["txt4"] = Request.Form["txt4"];
}

%>
<form id="Form1" method="post" runat="server">
<br/><INPUT name="txt1" type="text">
<br/><INPUT name="txt2" type="text">
<br/><INPUT name="txt3" type="text">
<br/><INPUT name="txt4" type="text">
<br/><input type="checkbox" name="override" />
<br/><INPUT name="btnSubmit" type="submit" value="Submit">
</form>
<%
Response.Write("<br>SecondLoop:");
foreach(string key in Session.Keys)
{
Response.Write(string.Format("<br/>{0}: {1}", key, Session[key]));
}

%>
</body>
</HTML>
================================

Is the above code able to repro the problem on your side? Or shall I miss
anything else so as to repro the problem?

Thanks,

Steven Cheng
Microsoft Online Support

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

Nov 19 '05 #6
Hello Steven,
Before we looking into depth of your code logic or your web shop, I'd
like
to confirm whether this is a environment specific problem. Based on my
local test, I can read and update Sessionstate(sqlserver mode) in the
aspx
inline code.


I had to add

<%@Page Debug="true" enablesessionstate="true" validateRequest="false"
Language="C#" %>
<%@Import Namespace="System.Web"%>
<%@Import Namespace="System.Web.SessionState"%>

to your code, to make it work, but everything is workin there with
sqlserver mode.
The guess I had is that it might be, cause we are defining really many
session-variables
in the whole project, there might be any limit, we reached after which
values get lost
or so, cause there is not any code mattering these session-variables
before in the page
and there is no session abandon or so.
Hopefully this helps you at least a bit ;)
Steve
Nov 19 '05 #7
Thanks for yoru reply.

Then, since this is a project/environment specific problem, it'll be hard
to repro it on ourside. Curerntly I'll lookup some former issues to see
whether there're any similiar problem with the one you encountered or
whether there're any known problems with SQL Session when using a lot of
session variables. I'll come back to you soon.

Thanks,

Steven Cheng
Microsoft Online Support

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

Nov 19 '05 #8
Hi Steve,

After reviewing some former issues, I didn't found any existing patterns
which will cause the problem you mentioned, also there're no limit for the
quantity of sessionState varialbes. From existing cases, I only found
someone who lose sessionstate when there're certain exceptions occur in
application(not specific to sqlserver mode) or when using in webfarm
scenario).....
So I think this is a environment/code specific problem. Due to the
limitation of the newsgroup, if you feel it an urgent issue, I'd suggest
you contact the PSS for some more thorough troubleshooting.

http://support.microsoft.com/default.aspx?scid=sz;en-us

Thanks,

Steven Cheng
Microsoft Online Support

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

Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Shorthouse | last post: by
2 posts views Thread by Steve Remer | last post: by
14 posts views Thread by Michael Carr | last post: by
2 posts views Thread by Ricky K. Rasmussen | last post: by
3 posts views Thread by Billy Horne | last post: by
4 posts views Thread by Chris | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.