How to serialize and object to use as a parameter in a URL?

J

Julia

Hi,

I need to serialize an object in such a way that it can be passed as
parameter in a URL

http://www.domain.com?object=%d793btng....

I did some reading and I came to the conclusion that I need to create a
custom formatter and implements the IFormatter interface

the problem is that I don't quit know how to implements the
IFormatter.Serialize function

1.How do I get the attribute of each property?

2.How can i get all properties,i guess I need to use reflection?

2.How do I track the object which already Serialized(assuming the object
contains other objects)

Note that I cannot use binary formatter or other,since the code which do the
deserialization is a client side java script

thanks in advance.
 
S

Scott Allen

Hi Julia:

Reflection would allow you to step through the public properties of
any object. The PropertyInfo class in the System.Reflection namespace
is pretty useful for getting the values of all properties:

PropertyInfo[] info = Type.GetType("System.Type").GetProperties();

Then use GetValue on each PropertyInfo to return the value of each
property as an object..

HTH,
 
N

Nicholas Paldino [.NET/C# MVP]

Additionally, you would have to encode the output to account for
characters that are not allowed.

Personally, I would choose to use the SOAP formatter and then use a POST
to post the contents to the server. The output of any object being
serialized is quite lengthy, and not suited for placement in a URL.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Scott Allen said:
Hi Julia:

Reflection would allow you to step through the public properties of
any object. The PropertyInfo class in the System.Reflection namespace
is pretty useful for getting the values of all properties:

PropertyInfo[] info = Type.GetType("System.Type").GetProperties();

Then use GetValue on each PropertyInfo to return the value of each
property as an object..

HTH,

--
Scott
http://www.OdeToCode.com


Hi,

I need to serialize an object in such a way that it can be passed as
parameter in a URL

http://www.domain.com?object=%d793btng....

I did some reading and I came to the conclusion that I need to create a
custom formatter and implements the IFormatter interface

the problem is that I don't quit know how to implements the
IFormatter.Serialize function

1.How do I get the attribute of each property?

2.How can i get all properties,i guess I need to use reflection?

2.How do I track the object which already Serialized(assuming the object
contains other objects)

Note that I cannot use binary formatter or other,since the code which do
the
deserialization is a client side java script

thanks in advance.
 
J

Julia

Thanks,i must use the URL since i am passing it using email
I am using Base64 to encode the output.


Thanks.


Nicholas Paldino said:
Additionally, you would have to encode the output to account for
characters that are not allowed.

Personally, I would choose to use the SOAP formatter and then use a POST
to post the contents to the server. The output of any object being
serialized is quite lengthy, and not suited for placement in a URL.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Scott Allen said:
Hi Julia:

Reflection would allow you to step through the public properties of
any object. The PropertyInfo class in the System.Reflection namespace
is pretty useful for getting the values of all properties:

PropertyInfo[] info = Type.GetType("System.Type").GetProperties();

Then use GetValue on each PropertyInfo to return the value of each
property as an object..

HTH,

--
Scott
http://www.OdeToCode.com


Hi,

I need to serialize an object in such a way that it can be passed as
parameter in a URL

http://www.domain.com?object=%d793btng....

I did some reading and I came to the conclusion that I need to create a
custom formatter and implements the IFormatter interface

the problem is that I don't quit know how to implements the
IFormatter.Serialize function

1.How do I get the attribute of each property?

2.How can i get all properties,i guess I need to use reflection?

2.How do I track the object which already Serialized(assuming the object
contains other objects)

Note that I cannot use binary formatter or other,since the code which do
the
deserialization is a client side java script

thanks in advance.
 
K

Kevin Spencer

Keep the QueryString under 255 characters...

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

Julia said:
Thanks,i must use the URL since i am passing it using email
I am using Base64 to encode the output.


Thanks.


message news:[email protected]...
Additionally, you would have to encode the output to account for
characters that are not allowed.

Personally, I would choose to use the SOAP formatter and then use a POST
to post the contents to the server. The output of any object being
serialized is quite lengthy, and not suited for placement in a URL.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Scott Allen said:
Hi Julia:

Reflection would allow you to step through the public properties of
any object. The PropertyInfo class in the System.Reflection namespace
is pretty useful for getting the values of all properties:

PropertyInfo[] info = Type.GetType("System.Type").GetProperties();

Then use GetValue on each PropertyInfo to return the value of each
property as an object..

HTH,

--
Scott
http://www.OdeToCode.com


Hi,

I need to serialize an object in such a way that it can be passed as
parameter in a URL

http://www.domain.com?object=%d793btng....

I did some reading and I came to the conclusion that I need to create a
custom formatter and implements the IFormatter interface

the problem is that I don't quit know how to implements the
IFormatter.Serialize function

1.How do I get the attribute of each property?

2.How can i get all properties,i guess I need to use reflection?

2.How do I track the object which already Serialized(assuming the object
contains other objects)

Note that I cannot use binary formatter or other,since the code which do
the
deserialization is a client side java script

thanks in advance.
 
J

Julia

Why?!?!

Kevin Spencer said:
Keep the QueryString under 255 characters...

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

Julia said:
Thanks,i must use the URL since i am passing it using email
I am using Base64 to encode the output.


Thanks.


message news:[email protected]...
Additionally, you would have to encode the output to account for
characters that are not allowed.

Personally, I would choose to use the SOAP formatter and then use
a
POST
to post the contents to the server. The output of any object being
serialized is quite lengthy, and not suited for placement in a URL.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi Julia:

Reflection would allow you to step through the public properties of
any object. The PropertyInfo class in the System.Reflection namespace
is pretty useful for getting the values of all properties:

PropertyInfo[] info = Type.GetType("System.Type").GetProperties();

Then use GetValue on each PropertyInfo to return the value of each
property as an object..

HTH,

--
Scott
http://www.OdeToCode.com


Hi,

I need to serialize an object in such a way that it can be passed as
parameter in a URL

http://www.domain.com?object=%d793btng....

I did some reading and I came to the conclusion that I need to
create
which
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top