Saturday, March 31, 2012
Session Tuturorial or Walkthrough for a newbie?
managment or some kind of state managment.
This is what I am doing, so maybe you can tell me which direction I should
look at going!
I have a app then once you fill in your query information and sumitt the
form you get my results page. On the results page I have a datagrid that
contains anywhere from 5 to 7000 rows that are shown in a OutLookGroup style
.
I am finding that the table the grid builds off is very large to maintain in
viewstate, sometimes 12mb+. What I would like to do is in my grid only keep
what I need to display the grid and my row ID field, but I need to store the
entire table (which is created on the fly based on the query) in state
somehow, then call back to it on post to retrieve my details to further
process the page.
So I guess I need to do the following,
1. create the session (or whatever)
2. process the query and save table to session
3. onclick function retrieve the table from session and do secondary query
4. contrinue to maintain the table in session
5. after timeout dispose/flush table.
Can anyone give me good direction on where I go to make this happen?
Thanks;
--
D @dotnet.itags.org. premierdataHi Dewright,
AS for the caching table question you mentioned, I think generally the
following code the what we commonly used:
DataSet ds = null;
if(Session["data_key"] == null)
{
QueryDataFromDataBaseAndStoreIntoSession
();
}
ds = Session["data_key"] as DataSet;
We can put it in Page_load and bind the grid when necessary(We may adjust
the code according to our actual code logic). Also , for large dataset, of
course we suggest disabling the DataGrid's ViewState and bind grid with
data retrieved from SessionState(or other cache store) in each
request/postback.
Also, how do you think of the ASP.NET's Cache collection? Each ASP.NET
application will has a Cache colleciton assosciated with it, (it's
application scope ), we can store datas in it and add a expire dependency
for it. So for your scenario, you can also consider storeing the large data
records in Cache (with a sessionid associated key if necessary).
Here are some good resources for understanding the SessionState and Cache
in ASP.NET:
#Understanding session state modes + FAQ
http://forums.asp.net/7504/ShowPost.aspx
#State Management & Caching
http://msdn.microsoft.com/asp.net/a...te/default.aspx
Hope helps. 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.)
Session Tuturorial or Walkthrough for a newbie?
managment or some kind of state managment.
This is what I am doing, so maybe you can tell me which direction I should
look at going!
I have a app then once you fill in your query information and sumitt the
form you get my results page. On the results page I have a datagrid that
contains anywhere from 5 to 7000 rows that are shown in a OutLookGroup style.
I am finding that the table the grid builds off is very large to maintain in
viewstate, sometimes 12mb+. What I would like to do is in my grid only keep
what I need to display the grid and my row ID field, but I need to store the
entire table (which is created on the fly based on the query) in state
somehow, then call back to it on post to retrieve my details to further
process the page.
So I guess I need to do the following,
1. create the session (or whatever)
2. process the query and save table to session
3. onclick function retrieve the table from session and do secondary query
4. contrinue to maintain the table in session
5. after timeout dispose/flush table.
Can anyone give me good direction on where I go to make this happen?
Thanks;
--
D @dotnet.itags.org. premierdataHi Dewright,
AS for the caching table question you mentioned, I think generally the
following code the what we commonly used:
DataSet ds = null;
if(Session["data_key"] == null)
{
QueryDataFromDataBaseAndStoreIntoSession();
}
ds = Session["data_key"] as DataSet;
We can put it in Page_load and bind the grid when necessary(We may adjust
the code according to our actual code logic). Also , for large dataset, of
course we suggest disabling the DataGrid's ViewState and bind grid with
data retrieved from SessionState(or other cache store) in each
request/postback.
Also, how do you think of the ASP.NET's Cache collection? Each ASP.NET
application will has a Cache colleciton assosciated with it, (it's
application scope ), we can store datas in it and add a expire dependency
for it. So for your scenario, you can also consider storeing the large data
records in Cache (with a sessionid associated key if necessary).
Here are some good resources for understanding the SessionState and Cache
in ASP.NET:
#Understanding session state modes + FAQ
http://forums.asp.net/7504/ShowPost.aspx
#State Management & Caching
http://msdn.microsoft.com/asp.net/a...te/default.aspx
Hope helps. 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.)
Thursday, March 29, 2012
session variable
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
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