Showing posts with label farm. Show all posts
Showing posts with label farm. Show all posts

Saturday, March 24, 2012

Serializing classes derived from dataset

Hi,

I am trying to store various objects within session. Due
to the site being hosted in a web farm we are going to
have to use either State Server or SQL Server to persist
the data in session. All of the objects are classes which
inherit from a typed dataset.

Looking at MSDN I have found the following two (what I
believe to be) relevent statements (from article Object
Serialization in the .NET Framework):

"Derived classes should call the GetObjectData method on
the base object if the latter implements ISerializable"

and

"When you derive a new class from one that implements
ISerializable, the derived class must implement both the
constructor as well as the GetObjectData method if it has
any variables that need to be serialized."

Since the Dataset implements ISerializable the above
statements indicate that I should override the
GetObjectData method. However if I try and override this
method I get a compile error stating:

"sub 'GetObjectData' cannot be declared 'Overrides'
because it does not override a sub in a base class."

I am also unable to call the method GetObjectData on the
base class as it is not accessible.

The classes which I am trying to persist have their own
properties, some of which are themselves objects which
inherit from datasets.

If I create a test class which inherits from a typed
dataset, and which has two additional properites (named
Property1 and Property2) the following XML is persisted:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="dsTemp"
targetNamespace="http://tempuri.org/dsTemp.xsd"
xmlns:mstns="http://tempuri.org/dsTemp.xsd"
xmlns="http://tempuri.org/dsTemp.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:element name="dsTemp" msdata:IsDataSet="true"
msdata:Property1="1" msdata:Property2="Aidan">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="InvoiceHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="InvoiceHeaderID"
msdata:ReadOnly="true" msdata:AutoIncrement="true"
type="xs:int" />
<xs:element name="POHeaderID" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="dsTempKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:InvoiceHeader" />
<xs:field xpath="mstns:InvoiceHeaderID" />
</xs:unique>
</xs:element>
</xs:schema
Note that the properties have been serialized, but have
been serialized as "<xs:element name="dsTemp"
msdata:IsDataSet="true" msdata:Property1="1"
msdata:Property2="Aidan">"

I can find no way in which I can de-serialize these fields.

Can someone please explain how I can have a class which
inherits from a dataset, and which I can then serialize
and de-serialize without losing the properties.

Thanks in advance

AidanNote that the xml which should have been displayed
indicated that the properties were included in a dataset
element as

msdata:Property1="1"
msdata:Property2="Aidan"

>--Original Message--
>Hi,
>I am trying to store various objects within session. Due
>to the site being hosted in a web farm we are going to
>have to use either State Server or SQL Server to persist
>the data in session. All of the objects are classes
which
>inherit from a typed dataset.
>Looking at MSDN I have found the following two (what I
>believe to be) relevent statements (from article Object
>Serialization in the .NET Framework):
>"Derived classes should call the GetObjectData method on
>the base object if the latter implements ISerializable"
>and
>"When you derive a new class from one that implements
>ISerializable, the derived class must implement both the
>constructor as well as the GetObjectData method if it has
>any variables that need to be serialized."
>Since the Dataset implements ISerializable the above
>statements indicate that I should override the
>GetObjectData method. However if I try and override this
>method I get a compile error stating:
>"sub 'GetObjectData' cannot be declared 'Overrides'
>because it does not override a sub in a base class."
>I am also unable to call the method GetObjectData on the
>base class as it is not accessible.
>The classes which I am trying to persist have their own
>properties, some of which are themselves objects which
>inherit from datasets.
>If I create a test class which inherits from a typed
>dataset, and which has two additional properites (named
>Property1 and Property2) the following XML is persisted:
><?xml version="1.0" encoding="utf-16"?>
><xs:schema id="dsTemp"
>targetNamespace="http://tempuri.org/dsTemp.xsd"
>xmlns:mstns="http://tempuri.org/dsTemp.xsd"
>xmlns="http://tempuri.org/dsTemp.xsd"
>xmlns:xs="http://www.w3.org/2001/XMLSchema"
>xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
>attributeFormDefault="qualified"
>elementFormDefault="qualified">
> <xs:element name="dsTemp" msdata:IsDataSet="true"
>msdata:Property1="1" msdata:Property2="Aidan">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element name="InvoiceHeader">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="InvoiceHeaderID"
>msdata:ReadOnly="true" msdata:AutoIncrement="true"
>type="xs:int" />
> <xs:element name="POHeaderID" type="xs:int"
>minOccurs="0" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:choice>
> </xs:complexType>
> <xs:unique name="dsTempKey1" msdata:PrimaryKey="true">
> <xs:selector xpath=".//mstns:InvoiceHeader" />
> <xs:field xpath="mstns:InvoiceHeaderID" />
> </xs:unique>
> </xs:element>
></xs:schema>
>Note that the properties have been serialized, but have
>been serialized as "<xs:element name="dsTemp"
>msdata:IsDataSet="true" msdata:Property1="1"
>msdata:Property2="Aidan">"
>I can find no way in which I can de-serialize these
fields.
>Can someone please explain how I can have a class which
>inherits from a dataset, and which I can then serialize
>and de-serialize without losing the properties.
>Thanks in advance
>Aidan
>.

Thursday, March 22, 2012

Serious issue: parts of my page render as not logged in, parts as logged in. Help!

I'm having a very difficult time with some of our new pages. We've
moved to a web farm, and it seems in spurts it will come where parts
of my page think the user is logged in, and parts think the user is
not logged in. It seems to happen to an entire control. (None of the
controls have OutputCache set)

For example, our login control on top will appear showing the user is
logged inw hen they have been redirected to RegNewUser, but RegNewUser
will display instead of redirecting as if the user were actually
logged in.

The MachineKey option in the web.config is set to a generated SHA1, so
the viewstate moves between the web servers just fine.

This seems to come in spurts where it will happen to a lot of users at
once, then it will stop coming. This is a serious problem on a
production website, I just don't know where to turn or how to debug --
everything looks fine!

I am also getting Forms Authentication failed events in my log:

Event code: 4005
Event message: Forms authentication failed for the request. Reason:
The ticket supplied has expired.
Event time: 4/11/2007 12:42:27 PM
Event time (UTC): 4/11/2007 7:42:27 PM
Event ID: 0a0a593d17984b41aa13b93254491326
Event sequence: 1161
Event occurrence: 13
Event detail code: 50202

Application information:
Application domain: /LM/W3SVC/1/Root-2-128207889508981002
Trust level: Full
Application Virtual Path: /
Application Path: E:\htdocs\mysite-pri\
Machine name: WEB1

Process information:
Process ID: 400
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Request information:
Request URL: http://www.mysite.com:8080/default.aspx
Request path: /default.aspx
User host address: 10.10.1.1
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Name to authenticate:

Custom event details:Make sure the cookie path is the same on all machines. Make sure that the Web
Site number (e.g., /LM/W3SVC/1/Root-2-128207889508981002 - the "/1/" after
W3SVC) is the same.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"pcloches@.gmail.com" wrote:

Quote:

Originally Posted by

I'm having a very difficult time with some of our new pages. We've
moved to a web farm, and it seems in spurts it will come where parts
of my page think the user is logged in, and parts think the user is
not logged in. It seems to happen to an entire control. (None of the
controls have OutputCache set)
>
For example, our login control on top will appear showing the user is
logged inw hen they have been redirected to RegNewUser, but RegNewUser
will display instead of redirecting as if the user were actually
logged in.
>
The MachineKey option in the web.config is set to a generated SHA1, so
the viewstate moves between the web servers just fine.
>
This seems to come in spurts where it will happen to a lot of users at
once, then it will stop coming. This is a serious problem on a
production website, I just don't know where to turn or how to debug --
everything looks fine!
>
I am also getting Forms Authentication failed events in my log:
>
Event code: 4005
Event message: Forms authentication failed for the request. Reason:
The ticket supplied has expired.
Event time: 4/11/2007 12:42:27 PM
Event time (UTC): 4/11/2007 7:42:27 PM
Event ID: 0a0a593d17984b41aa13b93254491326
Event sequence: 1161
Event occurrence: 13
Event detail code: 50202
>
Application information:
Application domain: /LM/W3SVC/1/Root-2-128207889508981002
Trust level: Full
Application Virtual Path: /
Application Path: E:\htdocs\mysite-pri\
Machine name: WEB1
>
Process information:
Process ID: 400
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
>
Request information:
Request URL: http://www.mysite.com:8080/default.aspx
Request path: /default.aspx
User host address: 10.10.1.1
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
>
Name to authenticate:
>
Custom event details:
>
>