State Management :: How To Serialize Objects

Jul 2, 2010

Is there any way or process to serialize the the objects?? i am trying to store the instance of few control in viewstate but it shows error msg that it is not a serialized object. should i perform some steps to serialize the objects ???

View 9 Replies


Similar Messages:

State Management :: Unable To Serialize The Session State In 'StateServer' And 'SQLServer' Mode

Dec 12, 2010

I am new to .net 4.0 and am using EF Model and SessionState Mode=SqlServer and I am getting this error below:

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

I checked the stack trace and its complaining about

[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("PoplarGroveModel", "tblMenuRole", "tblMenu", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(PoplarGroveDataModel.Menu), "tblRole",

[Code].....

I marked it as serializable but then it complains about System.Data.Objects.ObjectContext is not marked as serializable and hence throws the same error.

View 1 Replies

State Management :: Serialize TreeNode With Sql?

Jan 21, 2011

Currently I am working on SessionState with SQL. I have problem. I would like to serialize TreeNode. This TreeNode pbject will be assigned to Session and this is declare as below.

private _treeNode as TreeNode <-- member variable

how do I make this _treeNode seriablizable?

View 1 Replies

State Management :: How To Serialize An Object Into Cookie

Apr 1, 2010

I had an xml-serialization which worked fine, but as I have just knew it doesn't work in Opera browser. I think, it's security rules don't allow to write to cookies xml-content.What can I do? Can I use binary serialization or something else?

View 2 Replies

State Management :: Serialize/Deserialize A Custom Class In And Out Of A Session

Mar 18, 2011

I'm trying to save a custom class in a session, but it just never gets saved, along with other sessions. Note that my SessionMode = STATESERVER, and i cannot change it to INPROC as per our business requirement. This is my class

/*******START*******/
[Serializable]
public class User : ISerializable
{
private int _userId;
public int UserId
{
get { return _userId; }
set { _userId = value; }
}
//custom class
private TDB.tdbUser _tdbUserDetails;
public TDB.tdbUser tdbUserDetails
{
get { return _tdbUserDetails; }
set { _tdbUserDetails = value; }
}
//collection of custom class Sites
private List<Sites> _assignedSites;
public List<Sites> AssignedSites
{
get { return _assignedSites; }
set { _assignedSites = value; }
}
public User()
{
//Constructor code
}
/******SERIALIZATION*****/
protected User(SerializationInfo info, StreamingContext context)
{
this._userId = (int)info.GetValue("_userId", typeof(int));
this._assignedSites = (List<Sites>)info.GetValue("_assignedSites", typeof(List<Sites>));
this._tdbUserDetails = (TDB.tdbUser)info.GetValue("_tdbUserDetails", typeof(TDB.tdbUser));
}
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("_userId", this._userId);
info.AddValue("_assignedSites", this._assignedSites);
info.AddValue("_tdbUserDetails", this._tdbUserDetails);
}
}
/*******END*******/

The calling code is just this: (User)HttpContext.Current.Session["TDBUSER"];

View 2 Replies

State Management :: Manage Custom Objects And Session State?

Oct 6, 2010

I've created a whole bunch of rather complex classes and now i'm starting to work on the ASP.net user interface. Basically the user will open 1 page which will be used to load, edit, save an object. The object has many fields and they are often other classes i've created. To create a nice interface i've used popups and used AJAX to reload parts of the page to avoid reloading the whole thing.

My plan was to create the object and save it to the session. Then each time the page is loaded copy the object values to the asp fields and do the reverse when the page has been submitted copying the asp values to the object field then updating the session object.

So the code will go something like:

onload:

if session is not null load from session otherwise create new
this.txtID.text = object.id
this.txtName.text = object.name
etc etc

on submit:

object.id = this.txtID.text
object.name = this.txtName.text
etc etc
update session.

Is this what you guys would do? or am i over thinking this, seems like a lot of code to load all the object fields each time the page is opened and submitted etc.

Just looking to bounce ideas of off other developers :D

View 4 Replies

State Management :: How To Link The Objects Between Browser Session And Session Objects

May 10, 2010

Lets say I am doing a shoping cart. I authenticate the user with a session variable.For example:

If(Request.IsAuthenticated)
// Here I want to add to the shoping cart.
// Can I do the following
Session["Cart"] = "Washing Machine";
Now will this Session["Cart"] value which is washing machine here be unique to diff customers?

View 1 Replies

State Management :: Best Practise For Caching Objects For A List Of?

Dec 7, 2010

I've created a blog for my first asp.net website. Ive got a blog class as my object. Ive created a number of methods to access my blog articles using LINQ to SQL.

Each method returns a list of objects ready to be used in the appropriate web user control.

In my head i need to cache these lists of objects that are returned, but need to know the best way of approaching this. So i have come up with two possible options

1: Make one method to retrieve all blogs in a list<Blog> and cache this list to be used for all other methods or

2: Cache only the required methods that really need it.

View 3 Replies

State Management :: How Share The Application Objects Between The Server In Web Form

Mar 31, 2010

I have problem in maintaining the application objects in the server when it is deployed in the web farm.In our application i'm storing the sessionID and and the column value ( "tvktnx55vl5mzr453dmaehit " + "A101" ) in arraylist and storing it in application object. when i test this it is ok. but when we deploy it we have one issue that is we cannot share the application object in web farm.

View 1 Replies

State Management :: Session Objects Not Cleared As Expected After Upgrading To IIS7.5?

Sep 13, 2010

I've just upgraded my development machine from XP SP3 (IIS5.1) to Win7 x64 (IIS7.5)

Since doing this, my app has started to behave differently. Within it I store users' preferences/access levels using an instance of a class that I store within the Session object. This class is shown:

[Code]....

My requirement is that on each page request (other than the login page), the application should check that the Session object exists. The page data is therefore shown based on the values within the session object (e.g. which customer account they are using etc)...Previously on IIS5.1 if I was logged into the app, but made some changes to a file within App_Code, or Web.Config for example, when I then continued to use the app, I would get kicked out to the login page straight away. This is the intended behaviour. Now however, on IIS7.5, the app continues to provide access to the pages, but debugging shows that the session value has had all of its values set to 0 (zero). Therefore, the pages continue to load but the data shown is corrupted because the app no longer displays it accurately. Here is the code I use which (on IIS5.1) caught this occurence. Can anyone offer any advice on just what's now happening

[Code]....

I have tried changing this line:

[Code]....

View 11 Replies

State Management :: Objects In Session Variables Now Causing Slow-downs?

Oct 24, 2010

I've noticed that once I've instantiated 3-4 objects now, my ASPX page is running slower. The response from the server (which is my own PC) is taking longer.

With one or two objects, the performance is same. After I instantiate 3, it slows a little, and 4 just completely wears it down.

I've read this article: [URL]

that says to avoid using session variables especially storing objects into them. Well thats exactly what I'm doing. My object has about 10 methods(~30 lines of code each) and 20 fields.

My question is, if I want to persist object in memory for each user session, how else could I store them on each postback if not in the session variable>? I can't use application variable because thats shared and not thread safe.

View 3 Replies

Serialize Linq Objects Not Working?

Apr 14, 2010

Using the following code:

Private Sub MakeMeSomeXmlBeforeRyanGetsAngry()
Dim db As New MyDBDataContext
Dim customer = From c In db.Customers Select c
Dim dcs As New DataContractSerializer(GetType(Customer))
Dim sb As StringBuilder = New StringBuilder
Dim writer As XmlWriter = XmlWriter.Create(sb)
dcs.WriteObject(writer, customer)
Dim xml As String = sb.ToString
Response.Write(xml)
End Sub

I am attempting to serialize my linq collection of customers. But it keeps throwing

Type 'System.Data.Linq.DataQuery`1[MyDB.Customer]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types.

My issue is that I have already marked the dbml Serialization Mode to UniDirectional and when I check the dbml codebehind all of the DataContract()> and DataMember()> elements are there.

I am not sure how to proceed. I have tried adding various dataloadoptions and setting deferredloading to false, but no luck.

View 2 Replies

Unable To Serialize Session State

Dec 11, 2013

Getting error when trying to save structured arraylist into session Variable (see btnTS_Click below)

Code works on my desktop VS2012 devel system but not when posted to webserver we use.

Try It: [URL] ....

Code:
Public Class _Default
Inherits System.Web.UI.Page
Structure HoursData
Dim Project As String

[Code]...

View 9 Replies

Unable To Serialize Session State - Server Errors

Oct 14, 2010

We have been receiving reports of the following server error periodically from users.
[OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.]
[HttpException (0x80004005): Unable to serialize the session state.]
Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is "StateServer" or "SQLServer".

Once in a state where this error appears, it appears to be hit or miss whether the errors are reproducible locally. If they are, then we can usually reproduce them for a couple minutes, but not on every page hit. This usually tapers off on its own and usually has resolved itself by the time we get back in contact with the users. The Web Service has around 90-100 active connections during business hours. The only other site on this server is the staging version of this site, which gets hit very infrequently. The Session State is stored on the same SQLServer instance as the application database which is housed on a fairly large cluster of virtual machines.

Neither the Web Server or the SQLServer seemed to be taxed (either processor or memory-wise) while this is going on. The distribution of which pages are erroring seems to be comparable to the normal distribution for each page. There doesn't appear to be any pattern in terms of times of occurrence. We do have less errors on average on weekends (which correlates to normal site load), but even this appears to not be consistent. There also doesn't appear to be a correlation between the errors logged and any kind of logged performance monitor events. This includes an array of perfmon counters including:

.NET CLR Jit(w3wp)
otal # of IL Bytes Jitted
.NET CLR Jit(w3wp)IL Bytes Jitted / sec
.NET CLR Jit(w3wp)\% Time in Jit
.NET CLR Jit(w3wp)# of Methods Jitted
.NET CLR Jit(w3wp)# of IL Bytes Jitted
ASP.NET Apps v1.1.4322(__Total__)Requests Failed
ASP.NET Apps v1.1.4322(__Total__)Errors Unhandled During Execution/Sec
ASP.NET Apps v1.1.4322(__Total__)Errors Unhandled During Execution
ASP.NET Apps v1.1.4322(__Total__)Cache Total Turnover Rate
ASP.NET Apps v1.1.4322(__Total__)Errors During Preprocessing
ASP.NET Apps v1.1.4322(__Total__)Errors During Execution
ASP.NET Apps v1.1.4322(__Total__)Requests Executing
ASP.NET Apps v1.1.4322(__Total__)Requests Total
ASP.NET Apps v1.1.4322(__Total__)Errors Total
ASP.NET Apps v1.1.4322(__Total__)Sessions Abandoned
ASP.NET Apps v1.1.4322(__Total__)Errors Total/Sec
ASP.NET Apps v1.1.4322(__Total__)Anonymous Requests/Sec
ASP.NET Apps v1.1.4322(__Total__)Requests/Sec
ASP.NET Apps v1.1.4322(__Total__)Session SQL Server connections total
ASP.NET Apps v1.1.4322(__Total__)Cache Total Hit Ratio
ASP.NET v1.1.4322Requests Current
ASP.NET v1.1.4322Request Execution Time
MemoryPages/sec
Bytes Total/sec
PhysicalDisk(_Total)Avg. Disk Queue Length
Processor(_Total)\% Processor Time
Web Service CacheFile Cache Hits %
Web Service CacheFile Cache Misses
Web Service CacheFile Cache Hits
Web Service(_Total)Current Connections
Web Service(_Total)Post Requests/sec)

The only pattern I can see in the logs doesn't correlate to the occurrence of these errors, but is the only pattern I can see. Looking at the perfmon logs we are seeing a pattern where the "Total # of IL Bytes Jitted", "IL Bytes Jitted / sec", "% Time in Jit", "# of Methods Jitted", and "# of IL Bytes Jitted" counters for the staging site (which shouldn't be getting any traffic) doesn't pull data for a 20-50 minute period after which there is an immediate spike in "IL Bytes Jitted / sec" and a jump in "% Time in Jit" for 2-20 minute of up to 99% for the main site.

View 1 Replies

Serialize Linq To SQL Entities For Use In Out - Of - Proc Session State?

Mar 11, 2010

I need to put some of the entities created via a.dbml Linq-To-Sql file into Session State. Because I am using out-of-proc State Server, they need to be serializable. How can I achieve this? I have tried setting the Serialization mode in the .dbml file to 'Unidirectional'.

View 1 Replies

State Management :: Client And Server Side State Management?

Feb 25, 2011

when we go for client and server side state management in asp.net

View 2 Replies

State Management :: State Management Using Shared Class?

May 29, 2010

I am doing a POC of making my website run faster. Currently it stores huge object data in Session while passing information from one page to another. What I was thinking is to use shared methods and properties instead of session. It works, but wanted tocheck if this is an optimum way to do it. Below is the code that does not use session but still pass object data from one page to another:

[code]...

View 1 Replies

State Management :: State Management And Page Navigation?

Nov 18, 2010

i have a form on page1.aspx with several controls (textbox, dropdownlist, etc).on Page1 PageLoad event i load data from database and performe databinding.From Page1 a user can, by clicking a specific button, move to Page2.aspx to insert some details and, after saving details, he returns to page1.

if save changes are made on control on page1 before save them to db, obviously, these are lost on return from page2 (because are reloaded on pageload from db).How can i save control status between pages round trip?

View 3 Replies

State Management :: Get The Correct Concept For State Management?

Aug 16, 2010

i need to know the full concepts state manegemnt in asp.net,..in which site i will get the correct concept for state management....

View 4 Replies

State Management :: Application State And Session State?

Oct 2, 2010

User Interface: 2 Labels; 1 Buttons

Requirements: Create a Web Page in ASPx that will do the following:

1)One label will provide a count of how many times Button 1 has been clicked in the current session.

2)One label will provide a count of how many times Button 1 has been clicked by all users of the application. The Application Code for the Button should start at 100 (set this in the Global.asax file). this is what i have so far but i cant seem to get the application state to work properly.

aspx.vb

Partial Class _Default
Inherits System.Web.UI.Page
Dim clickcount As Integer

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Session("ClickCount") Is Nothing Then
clickcount = 0
Else
clickcount = CInt(Session("ClickCount"))
End If
If Not IsPostBack Then
If Request.Cookies("UserName") IsNot Nothing Then
Label1.Text = "Welcome Back " & Request.Cookies("UserName").Value & "."
End If
End If
Dim clickCounta As Integer = CInt(Application("ClickCount"))
End Sub
Protected Sub PostBackSession_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.Click
clickcount += 1
lblClkCnt.Text = "Current Click Count is " & clickcount
Application.Lock()
Dim clickCounta As Integer = CInt(Application("ClickCount"))
clickCounta += 1
Application("ClickCount") = clickCounta
Application.UnLock()
AppClick.Text = clickCounta
Dim nameCookie As New HttpCookie("UserName", _
TextBox1.Text)
nameCookie.Expires = Now.AddYears(1)
Response.Cookies.Add(nameCookie)
End Sub
Protected Sub PostBackSession_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.PreRender
Session("ClickCount") = clickcount
Application("ClickCount") = clickcount
End Sub
End Class
global.asax
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(Application("ClickCount"))
Application.Add("ClickCount", 0)
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(HttpContext.Current.Application("ClickCount"))
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub

View 3 Replies

State Management :: Session Mode State Server - Sending Asynchronous Request

Nov 5, 2010

Customer were getting "View State Validation Error" due to worker process recycling at our production webserver and to fix that i applied machinekey and then move my Session state Mode from In Proc to State Server to retain session data and not kick out the customer to relogin. I had serialization issue with one object which has to be stored in session but when i moved it out of session i could able to resolve the issue.

But doing all these i was partly successfull in keeping the user in their session when Worker Process recycle event occurs.I was able to refresh the page or make a post back by clicking the refresh button and also able to retain the session values. But the Problem occurs when sending asynchronous request to server which we do periodically every 15 minutes from the moment the user logs in.The web page doesnot update data on website when sending asynchronous request.By Debugging I found at this particular code point it fails to make a postback which is required.

<%=GetHintFromServer%> (When there is no Worker Process recycle i t gets replaced by
WebForm_DoCallback('__Page',message,ShowHint,null,null,false) on postback) Everything works fine when there is no Worker Process Recyling but when it happens looks like sending request asynchronously using javascript fails .Remember When I make a post back by manually clicking submit button everything works fine.

SendRequest(Asynchronous)
function SendRequest(msg, isBusy, chartMsg, vesselMsg)
{
try
{
//confirm("msg"+msg+"isBusy"+isBusy+"chartMsg"+chartMsg+"VesselMsg"+vesselMsg);
_busy = isBusy;
if(chartMsg != null)
{
//confirm("chartMsg"+chartMsg);
_element.SetMessage(true, chartMsg);
}
if(vesselMsg != null)
{
confirm("chartMsg"+vesselMsg);
_element.ShowVesselLoading(true, vesselMsg);
}
_stuckWatchdog = setTimeout( "ClearPendingRequest();", 60000);
var message = msg;
var context = '';
<%=GetHintFromServer%>
}
catch(e)
{
alert( "Exception error on SendRequest(): " + e);
}
}

View 2 Replies

State Management :: Custom Control: State Restoring For Controls Created With CreateChildControls

Dec 22, 2010

Let me explain, describing the scenario:In a custom server control (in my case, derived from CompositeControl), in the overidden CreateChildControls method I create a complex tree of subcontrols, using information from a db.The db provides both information on which controls I need to create (the user interface's structure) and the data used to fill these controls.Than the user can interact with the control and change the data (that becomes different to what stored on db).

My custom control lives in the same page where there are other controls, obviously.And these controls can cause a postback at any time.What I need is that my custom control keeps the data entered by the user across these postback, without reverting to the original data and loose the user data entry.

Here is the first doubt:

1)I create the subcontrols dinamically in the CreateChildControls at any page refresh (both on first call than on postback).I know that the framework solves the reference between the posted data and the controls I create in the CreateChildControls in order to set properties and raise control events, but can you tell me when and how it actually does this? In which phase of page life cycle? What happens after the CreateChildControls?

A second doubt:2)If the user interface structure must change as a consequence of the data entered, I had to execute CreateChildControls twice (the first time to recreate the original interface to get the events and the second time to create the new interface)
In which phase of page/control lifecycle do I have to make the second call to CreateChildControls? I do it on Prerender now, but is it right or wrong, and why?

View 1 Replies

State Management :: Maintain Page View State In Roundtrip Between Webpages?

Jun 15, 2010

I am having a ASP.net application it having three pages ,page 1,page 2,page 3,when the user navigating between this pages I want to maintain the view state in page level after postbacks(i.e.) .If a user visits page 3, passing some query loads some data .then he moves to page 1 doing some entries .after that he once again moves to page 3 now I want to display the data previously available at the time he moves to page 1, same
way I want to do to my three pages up to the user logging out.

View 8 Replies

State Management :: Recreate State Session Database In SQL Server 2008?

Apr 5, 2010

Our ASP.NET App uses ASP State Session Management and has been rebuilt about 2 years ago [With .NET Framework 2.0]. We are currently in .NET framework 3.5 and have moved to SQL Server 2008 - but continue to use the same ASPState database. The State database has been upgraded to SQL Server 2008. Since then we have are seeing timouts/locks on ASPStateTempSessions table. I am wondering if we have to rebuild this database from scratch with some newer scripts?

View 2 Replies

State Management :: Asp Create New Session State Cookie Each Time On Debugging?

Jan 21, 2011

I'm using the following line of code to display the number of users currently logged on:

lblNoOfUsers.Text = Membership.GetNumberOfUsersOnline().ToString()

I'm still debugging my application so it's on the local server. As I debug and stop then debug again, eventually lblNoOfUsers.text turns to "0" instead of "1", even as I'm navigating my application. It only turns to "1" again if I log out and sign back in. It's almost as though Membership.GetNumberOfUsersOnline my login are referencing two different session states. How is this possible? Does asp.net create a new session state cookie each time I start debugging?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved