473,388 Members | 1,326 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,388 software developers and data experts.

View State and Server caching

My application is using ASP.NET 3.0 and My ASPX pages contain Master page,
and content page. The content page (.aspx) has various User controls (ascx).
My page view state is significantly large and I am looking for some smart way
to rfeduce the page size. So I indentified to manipulate ViewState. When page
is posted I will park the ViewState on Server and viewState will not move
back and forth. I am doing code as below in Page level by overrriding below
methods.

protected override void SavePageStateToPersistenceMedium(object viewState)
{
string str = "VIEWSTATE_" + Request.UserHostAddress + "_" +
DateTime.Now.Ticks.ToString();
Cache.Add(str, viewState, null,
DateTime.Now.AddMinutes(Session.Timeout), TimeSpan.Zero,
CacheItemPriority.Default, null);
RegisterHiddenField("__VIEWSTATE_KEY", str);
RegisterHiddenField("__VIEWSTATE", "");
}

protected override object LoadPageStateFromPersistenceMedium()
{
string str = Request.Form["__VIEWSTATE_KEY"];
if (!str.StartsWith("VIEWSTATE_"))
{
throw new Exception("Invalid viewstate key:" + str);
}
return Cache[str];
}

This is not working good for me. My pages get invalid viewState errors. I am
using Workflows too. Any idea how these methods can be better tuned when a
page contains multiple user controls.

Thanks
Aug 8 '08 #1
1 1574
So how is viewstate going to get to the client if you park it on the server?
It must move there eventually right? I suggest you look at reducing the size
of viewstate first but turning it off controls and pages that don't require
it. Remember, items like textbox don't need it. There's also control state
which is more efficient and tends to be lighter. However, I think you are
heading in the right direction for optimization.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
-------------------------------------------------------
"abcd" <ab**@discussions.microsoft.comwrote in message
news:CE**********************************@microsof t.com...
My application is using ASP.NET 3.0 and My ASPX pages contain Master page,
and content page. The content page (.aspx) has various User controls
(ascx).
My page view state is significantly large and I am looking for some smart
way
to rfeduce the page size. So I indentified to manipulate ViewState. When
page
is posted I will park the ViewState on Server and viewState will not move
back and forth. I am doing code as below in Page level by overrriding
below
methods.

protected override void SavePageStateToPersistenceMedium(object
viewState)
{
string str = "VIEWSTATE_" + Request.UserHostAddress + "_" +
DateTime.Now.Ticks.ToString();
Cache.Add(str, viewState, null,
DateTime.Now.AddMinutes(Session.Timeout), TimeSpan.Zero,
CacheItemPriority.Default, null);
RegisterHiddenField("__VIEWSTATE_KEY", str);
RegisterHiddenField("__VIEWSTATE", "");
}

protected override object LoadPageStateFromPersistenceMedium()
{
string str = Request.Form["__VIEWSTATE_KEY"];
if (!str.StartsWith("VIEWSTATE_"))
{
throw new Exception("Invalid viewstate key:" + str);
}
return Cache[str];
}

This is not working good for me. My pages get invalid viewState errors. I
am
using Workflows too. Any idea how these methods can be better tuned when a
page contains multiple user controls.

Thanks
Aug 10 '08 #2

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

Similar topics

3
by: Mark | last post by:
Ok, I know that .net inherently does not share session data across asp.net projects, but is there any decent work around to this. We already have a big chunk of our application using the asp.net...
2
by: John A Grandy | last post by:
for high traffic public websites , what are the proven options for session-state storage & management ? is an out-of-process state-server generally preferred over a sql-server ? what are the...
3
by: Philip Tripp | last post by:
I've read numerous sources stating that view state can be disabled per control, and per page, but can't seem to keep web form controls from remembering their state on a postback. I'm using VS.Net...
14
by: Lauri Kotilainen | last post by:
Hi, I've already tried several avenues for this, and am quite stumped. The issue I'm facing is a weird case of sessions getting mixed up (ie. users seeing each others' data). Apparently this...
10
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung...
2
by: Ned Balzer | last post by:
Hi, Apologies if this is a newbie question, I haven't found the answer in any faqs. I have an asp.net 2.0 page that sets session variables and then redirects to another page. For the page...
0
by: jason | last post by:
hi experts, support.microsoft.com/kb/917072 and http://msdn.microsoft.com/msdnmag/issues/06/07/WebAppFollies/ As pointed out in these articles, users might get session variables belong to...
2
by: theGecko | last post by:
I am aware that web services should be entirely stateless and it seems to be recognised as bad design to keep state. BUT, some of the methods we are exposing are extremel complicated and need...
11
by: Joseph Geretz | last post by:
I've been looking at two approaches for the maintenance of Session state for a Web Service application. One approach uses the old familiar Session object which I've used in the past for Web...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.